From 6989ed6c5f1074c60d7674c1ebbe9f495711e1d5 Mon Sep 17 00:00:00 2001 From: Tai Lai Date: Wed, 6 Nov 2024 09:55:33 -0800 Subject: [PATCH] feat(amazonq): add new languages for auto scan (#5934) ## Problem Auto scan and security issue components are not enabled for some languages available in code scan service. ## Solution Add support for new languages for code scan. --- License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --- ...ture-79cd3c68-8432-44b5-a004-dd98b8e858d8.json | 4 ++++ .../util/securityScanLanguageContext.test.ts | 15 ++++++++++----- .../core/src/codewhisperer/models/constants.ts | 7 +++++++ .../util/securityScanLanguageContext.ts | 7 +++++++ 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Feature-79cd3c68-8432-44b5-a004-dd98b8e858d8.json diff --git a/packages/amazonq/.changes/next-release/Feature-79cd3c68-8432-44b5-a004-dd98b8e858d8.json b/packages/amazonq/.changes/next-release/Feature-79cd3c68-8432-44b5-a004-dd98b8e858d8.json new file mode 100644 index 00000000000..9bbef151fd7 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-79cd3c68-8432-44b5-a004-dd98b8e858d8.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "Security Scan: Auto-scan now supports JSX, TSX, Kotlin, Scala, and Shell files." +} diff --git a/packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts b/packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts index 71ece8c66a9..cb0a51fdad8 100644 --- a/packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts +++ b/packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts @@ -17,20 +17,20 @@ describe('securityScanLanguageContext', function () { ['javascript', true], ['typescript', true], ['jsx', false], - ['javascriptreact', false], - ['typescriptreact', false], + ['javascriptreact', true], + ['typescriptreact', true], ['tsx', false], ['csharp', true], ['python', true], ['c', true], ['cpp', true], ['go', true], - ['kotlin', false], + ['kotlin', true], ['php', true], ['ruby', true], ['rust', false], - ['scala', false], - ['shellscript', false], + ['scala', true], + ['shellscript', true], ['sql', false], ['json', true], ['yaml', true], @@ -92,7 +92,9 @@ describe('securityScanLanguageContext', function () { ['java', 'java'], ['python', 'python'], ['javascript', 'javascript'], + ['javascriptreact', 'javascript'], ['typescript', 'typescript'], + ['typescriptreact', 'typescript'], ['csharp', 'csharp'], ['go', 'go'], ['ruby', 'ruby'], @@ -112,6 +114,9 @@ describe('securityScanLanguageContext', function () { ['java-properties', 'plaintext'], ['go.mod', 'plaintext'], ['go.sum', 'plaintext'], + ['kotlin', 'kotlin'], + ['scala', 'scala'], + ['shellscript', 'shell'], ] for (const [securityScanLanguageId, expectedCwsprLanguageId] of securityScanLanguageIds) { diff --git a/packages/core/src/codewhisperer/models/constants.ts b/packages/core/src/codewhisperer/models/constants.ts index 52b5b27d3e8..7fba6a33803 100644 --- a/packages/core/src/codewhisperer/models/constants.ts +++ b/packages/core/src/codewhisperer/models/constants.ts @@ -263,7 +263,9 @@ export const securityScanLanguageIds = [ 'java', 'python', 'javascript', + 'javascriptreact', 'typescript', + 'typescriptreact', 'csharp', 'go', 'ruby', @@ -286,6 +288,11 @@ export const securityScanLanguageIds = [ 'java-properties', 'go.mod', 'go.sum', + 'kotlin', + 'scala', + 'sh', + 'shell', + 'shellscript', ] as const export type SecurityScanLanguageId = (typeof securityScanLanguageIds)[number] diff --git a/packages/core/src/codewhisperer/util/securityScanLanguageContext.ts b/packages/core/src/codewhisperer/util/securityScanLanguageContext.ts index 466a558a2eb..1966bbac402 100644 --- a/packages/core/src/codewhisperer/util/securityScanLanguageContext.ts +++ b/packages/core/src/codewhisperer/util/securityScanLanguageContext.ts @@ -17,7 +17,9 @@ export class SecurityScanLanguageContext { java: 'java', python: 'python', javascript: 'javascript', + javascriptreact: 'javascript', typescript: 'typescript', + typescriptreact: 'typescript', csharp: 'csharp', go: 'go', golang: 'go', @@ -40,6 +42,11 @@ export class SecurityScanLanguageContext { 'java-properties': 'plaintext', 'go.mod': 'plaintext', 'go.sum': 'plaintext', + kotlin: 'kotlin', + scala: 'scala', + sh: 'shell', + shell: 'shell', + shellscript: 'shell', }) }