Skip to content

Commit 2c8d666

Browse files
authored
fix(amazonq): update security scan languages (aws#5523)
## Problem Sometimes security issues have a Diagnostic but not SecurityIssueHover issue. This happens when the document's languageId is not enabled when registering the hover/code actions provider. ## Solution Update the enabled languageIds for security scans feature. --- <!--- REMINDER: Ensure that your PR meets the guidelines in CONTRIBUTING.md --> License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 5073cc8 commit 2c8d666

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe('securityScanLanguageContext', function () {
3939
['html', false],
4040
['r', false],
4141
['vb', false],
42+
['xml', false],
43+
['toml', false],
44+
['pip-requirements', false],
45+
['java-properties', false],
46+
['go.mod', false],
47+
['go.sum', false],
4248
]
4349

4450
beforeEach(async function () {
@@ -100,6 +106,12 @@ describe('securityScanLanguageContext', function () {
100106
['packer', 'tf'],
101107
['plaintext', 'plaintext'],
102108
['jsonc', 'json'],
109+
['xml', 'plaintext'],
110+
['toml', 'plaintext'],
111+
['pip-requirements', 'plaintext'],
112+
['java-properties', 'plaintext'],
113+
['go.mod', 'plaintext'],
114+
['go.sum', 'plaintext'],
103115
]
104116

105117
for (const [securityScanLanguageId, expectedCwsprLanguageId] of securityScanLanguageIds) {

packages/core/src/codewhisperer/activation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ export async function activate(context: ExtContext): Promise<void> {
283283
ImportAdderProvider.instance
284284
),
285285
vscode.languages.registerHoverProvider(
286-
[...CodeWhispererConstants.platformLanguageIds],
286+
[...CodeWhispererConstants.securityScanLanguageIds],
287287
SecurityIssueHoverProvider.instance
288288
),
289289
vscode.languages.registerCodeActionsProvider(
290-
[...CodeWhispererConstants.platformLanguageIds],
290+
[...CodeWhispererConstants.securityScanLanguageIds],
291291
SecurityIssueCodeActionProvider.instance
292292
),
293293
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange)

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ export const securityScanLanguageIds = [
258258
'c',
259259
'cpp',
260260
'php',
261+
'xml',
262+
'toml',
263+
'pip-requirements',
264+
'java-properties',
265+
'go.mod',
266+
'go.sum',
261267
] as const
262268

263269
export type SecurityScanLanguageId = (typeof securityScanLanguageIds)[number]

packages/core/src/codewhisperer/util/securityScanLanguageContext.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export class SecurityScanLanguageContext {
3434
c: 'c',
3535
cpp: 'cpp',
3636
php: 'php',
37+
xml: 'plaintext', // xml does not exist in CodewhispererLanguage
38+
toml: 'plaintext',
39+
'pip-requirements': 'plaintext',
40+
'java-properties': 'plaintext',
41+
'go.mod': 'plaintext',
42+
'go.sum': 'plaintext',
3743
})
3844
}
3945

0 commit comments

Comments
 (0)