Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 40 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"mergeReports": "ts-node ./scripts/mergeReports.ts"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.293",
"@aws-toolkits/telemetry": "^1.0.295",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ describe('securityScanHandler', function () {
assert.equal(aggregatedCodeScanIssueList.length, 2)
assert.equal(aggregatedCodeScanIssueList[0].issues.length, 3)
})

it('should set autoDetected based on scope', async function () {
mockClient.listCodeScanFindings.resolves(
buildMockListCodeScanFindingsResponse(JSON.stringify([buildRawCodeScanIssue()]))
)
for (const [scope, expectedValue] of [
[CodeAnalysisScope.FILE_AUTO, true],
[CodeAnalysisScope.FILE_ON_DEMAND, false],
[CodeAnalysisScope.PROJECT, false],
] as [CodeAnalysisScope, boolean][]) {
const aggregatedCodeScanIssueList = await listScanResults(
mockClient,
'jobId',
'codeScanFindingsSchema',
['projectPath'],
scope,
undefined
)
assert.ok(
aggregatedCodeScanIssueList.every((item) =>
item.issues.every((issue) => issue.autoDetected === expectedValue)
)
)
}
})
})

describe('mapToAggregatedList', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/codewhisperer/commands/basicCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ export const applySecurityFix = Commands.declare(
result: 'Succeeded',
credentialStartUrl: AuthUtil.instance.startUrl,
codeFixAction: 'applyFix',
autoDetected: targetIssue.autoDetected,
codewhispererCodeScanJobId: targetIssue.scanJobId,
}
let languageId = undefined
try {
Expand Down Expand Up @@ -711,6 +713,7 @@ export const generateFix = Commands.declare(
} else {
hasSuggestedFix = suggestedFix !== undefined
}
telemetry.record({ includesFix: hasSuggestedFix })
const updatedIssue: CodeScanIssue = {
...targetIssue,
fixJobId: jobId,
Expand Down Expand Up @@ -755,6 +758,8 @@ export const generateFix = Commands.declare(
findingId: targetIssue.findingId,
ruleId: targetIssue.ruleId,
variant: refresh ? 'refresh' : undefined,
autoDetected: targetIssue.autoDetected,
codewhispererCodeScanJobId: targetIssue.scanJobId,
})
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ export interface CodeScanIssue {
scanJobId: string
language: string
fixJobId?: string
autoDetected?: boolean
}

export interface AggregatedCodeScanIssue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function listScanResults(
if (existsSync(filePath) && statSync(filePath).isFile()) {
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
filePath: filePath,
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId)),
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId, scope)),
}
aggregatedCodeScanIssueList.push(aggregatedCodeScanIssue)
}
Expand All @@ -92,7 +92,7 @@ export async function listScanResults(
if (existsSync(maybeAbsolutePath) && statSync(maybeAbsolutePath).isFile()) {
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
filePath: maybeAbsolutePath,
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId)),
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId, scope)),
}
aggregatedCodeScanIssueList.push(aggregatedCodeScanIssue)
}
Expand All @@ -103,7 +103,8 @@ export async function listScanResults(
function mapRawToCodeScanIssue(
issue: RawCodeScanIssue,
editor: vscode.TextEditor | undefined,
jobId: string
jobId: string,
scope: CodeWhispererConstants.CodeAnalysisScope
): CodeScanIssue {
const isIssueTitleIgnored = CodeWhispererSettings.instance.getIgnoredSecurityIssues().includes(issue.title)
const isSingleIssueIgnored =
Expand All @@ -130,6 +131,7 @@ function mapRawToCodeScanIssue(
visible: !isIssueTitleIgnored && !isSingleIssueIgnored,
scanJobId: jobId,
language,
autoDetected: scope === CodeWhispererConstants.CodeAnalysisScope.FILE_AUTO,
}
}

Expand Down
Loading