Skip to content

Commit bedea64

Browse files
Merge master into feature/emr
2 parents 0132ab9 + 76b4d88 commit bedea64

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Security Scan: Fixes an issue that incorrectly removes hardcoded credentials detections from auto scans."
4+
}

packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,24 @@ describe('securityScanHandler', function () {
180180
assert.equal(codeScanIssueMap.size, 1)
181181
assert.equal(codeScanIssueMap.get('file1.ts')?.length, 2)
182182
})
183+
184+
it('should handle issue filtering with redacted code', () => {
185+
const json = JSON.stringify([
186+
{
187+
filePath: 'file1.ts',
188+
startLine: 1,
189+
endLine: 2,
190+
codeSnippet: [
191+
{ number: 1, content: '**** *' },
192+
{ number: 2, content: '**** *' },
193+
],
194+
},
195+
{ filePath: 'file1.ts', startLine: 3, endLine: 3, codeSnippet: [{ number: 3, content: '**** **' }] },
196+
])
197+
198+
mapToAggregatedList(codeScanIssueMap, json, editor, CodeAnalysisScope.FILE)
199+
assert.strictEqual(codeScanIssueMap.size, 1)
200+
assert.strictEqual(codeScanIssueMap.get('file1.ts')?.length, 1)
201+
})
183202
})
184203
})

packages/core/src/codewhisperer/service/securityScanHandler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ export function mapToAggregatedList(
123123
for (let lineNumber = issue.startLine; lineNumber <= issue.endLine; lineNumber++) {
124124
const line = editor.document.lineAt(lineNumber - 1)?.text
125125
const codeContent = issue.codeSnippet.find((codeIssue) => codeIssue.number === lineNumber)?.content
126-
if (line !== codeContent) {
127-
return false
126+
if (codeContent?.includes('***')) {
127+
// CodeSnippet contains redacted code so we can't do a direct comparison
128+
return line.length === codeContent.length
129+
} else {
130+
return line === codeContent
128131
}
129132
}
130133
}

0 commit comments

Comments
 (0)