Skip to content

Commit a5b49c5

Browse files
authored
revert(amazonq): generate scanName from workspace config aws#6679 (aws#6730)
This reverts commit 62d3ec1. ## Problem Scan name change is causing unexpected behavior from the service. ## Solution Temporarily revert this change --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 57fa1d6 commit a5b49c5

File tree

6 files changed

+6
-70
lines changed

6 files changed

+6
-70
lines changed

packages/amazonq/.changes/next-release/Feature-90704e88-3ab3-4030-8bc6-fdde95aa3923.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import {
1515
ListCodeScanFindingsResponse,
1616
pollScanJobStatus,
1717
SecurityScanTimedOutError,
18-
generateScanName,
1918
} from 'aws-core-vscode/codewhisperer'
20-
import { getStringHash, timeoutUtils } from 'aws-core-vscode/shared'
19+
import { timeoutUtils } from 'aws-core-vscode/shared'
2120
import assert from 'assert'
2221
import sinon from 'sinon'
2322
import * as vscode from 'vscode'
@@ -321,37 +320,4 @@ describe('securityScanHandler', function () {
321320
await assert.rejects(() => pollPromise, SecurityScanTimedOutError)
322321
})
323322
})
324-
325-
describe('generateScanName', function () {
326-
const clientId = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
327-
328-
it('generates scan name for FILE_AUTO scope', function () {
329-
const result = generateScanName(['/some/root/path'], CodeAnalysisScope.FILE_AUTO, '/path/to/some/file')
330-
assert.strictEqual(result, getStringHash(`${clientId}::/path/to/some/file::FILE_AUTO`))
331-
})
332-
333-
it('generates scan name for FILE_ON_DEMAND scope', function () {
334-
const result = generateScanName(['/some/root/path'], CodeAnalysisScope.FILE_ON_DEMAND, '/path/to/some/file')
335-
assert.strictEqual(result, getStringHash(`${clientId}::/path/to/some/file::FILE_ON_DEMAND`))
336-
})
337-
338-
it('generates scan name for PROJECT scope with a single project root', function () {
339-
const result = generateScanName(['/some/root/path'], CodeAnalysisScope.PROJECT)
340-
assert.strictEqual(result, getStringHash(`${clientId}::/some/root/path::PROJECT`))
341-
})
342-
343-
it('generates scan name for PROJECT scope with multiple project roots', function () {
344-
const result = generateScanName(['/some/root/pathB', '/some/root/pathA'], CodeAnalysisScope.PROJECT)
345-
assert.strictEqual(result, getStringHash(`${clientId}::/some/root/pathA,/some/root/pathB::PROJECT`))
346-
})
347-
348-
it('does not exceed 126 characters', function () {
349-
let reallyDeepFilePath = ''
350-
for (let i = 0; i < 100; i++) {
351-
reallyDeepFilePath += '/some/deep/path'
352-
}
353-
const result = generateScanName(['/some/root/path'], CodeAnalysisScope.FILE_ON_DEMAND, reallyDeepFilePath)
354-
assert.ok(result.length <= 126)
355-
})
356-
})
357323
})

packages/core/src/codewhisperer/commands/startSecurityScan.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
listScanResults,
1919
throwIfCancelled,
2020
getLoggerForScope,
21-
generateScanName,
2221
} from '../service/securityScanHandler'
2322
import { runtimeLanguageContext } from '../util/runtimeLanguageContext'
2423
import {
@@ -39,6 +38,7 @@ import path from 'path'
3938
import { ZipMetadata, ZipUtil } from '../util/zipUtil'
4039
import { debounce } from 'lodash'
4140
import { once } from '../../shared/utilities/functionUtils'
41+
import { randomUUID } from '../../shared/crypto'
4242
import { CodeAnalysisScope, ProjectSizeExceededErrorMessage, SecurityScanStep } from '../models/constants'
4343
import {
4444
CodeScanJobFailedError,
@@ -185,7 +185,7 @@ export async function startSecurityScan(
185185
}
186186
let artifactMap: ArtifactMap = {}
187187
const uploadStartTime = performance.now()
188-
const scanName = generateScanName(projectPaths, scope, fileName)
188+
const scanName = randomUUID()
189189
try {
190190
artifactMap = await getPresignedUrlAndUpload(client, zipMetadata, scope, scanName)
191191
} finally {

packages/core/src/codewhisperer/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,7 @@ export { DocumentChangedSource, KeyStrokeHandler, DefaultDocumentChangedType } f
7272
export { ReferenceLogViewProvider } from './service/referenceLogViewProvider'
7373
export { LicenseUtil } from './util/licenseUtil'
7474
export { SecurityIssueProvider } from './service/securityIssueProvider'
75-
export {
76-
listScanResults,
77-
mapToAggregatedList,
78-
pollScanJobStatus,
79-
generateScanName,
80-
} from './service/securityScanHandler'
75+
export { listScanResults, mapToAggregatedList, pollScanJobStatus } from './service/securityScanHandler'
8176
export { CodeWhispererCodeCoverageTracker } from './tracker/codewhispererCodeCoverageTracker'
8277
export { TelemetryHelper } from './util/telemetryHelper'
8378
export { LineSelection, LineTracker } from './tracker/lineTracker'

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ import { runtimeLanguageContext } from '../util/runtimeLanguageContext'
4141
import { FeatureUseCase } from '../models/constants'
4242
import { UploadTestArtifactToS3Error } from '../../amazonqTest/error'
4343
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
44-
import { getStringHash } from '../../shared/utilities/textUtilities'
45-
import { getClientId } from '../../shared/telemetry/util'
46-
import globals from '../../shared/extensionGlobals'
4744
import { AmazonqCreateUpload, Span, telemetry } from '../../shared/telemetry/telemetry'
4845
import { AuthUtil } from '../util/authUtil'
4946

@@ -436,21 +433,3 @@ function getPollingTimeoutMsForScope(scope: CodeWhispererConstants.CodeAnalysisS
436433
? CodeWhispererConstants.expressScanTimeoutMs
437434
: CodeWhispererConstants.standardScanTimeoutMs
438435
}
439-
440-
/**
441-
* Generates a scanName that unique identifies a user's workspace configuration for a Q code review.
442-
*
443-
* @param projectPaths List of project root paths
444-
* @param scope {@link CodeWhispererConstants.CodeAnalysisScope} Scope of files included in the code review
445-
* @param fileName File name of the file being reviewed, or pass undefined for workspace review
446-
* @returns A string hash that uniquely identifies the workspace configuration
447-
*/
448-
export function generateScanName(
449-
projectPaths: string[],
450-
scope: CodeWhispererConstants.CodeAnalysisScope,
451-
fileName?: string
452-
) {
453-
const clientId = getClientId(globals.globalState)
454-
const projectId = fileName ?? projectPaths.sort((a, b) => a.localeCompare(b)).join(',')
455-
return getStringHash(`${clientId}::${projectId}::${scope}`)
456-
}

packages/core/src/testE2E/codewhisperer/securityScan.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import {
1818
createScanJob,
1919
pollScanJobStatus,
2020
listScanResults,
21-
generateScanName,
2221
} from '../../codewhisperer/service/securityScanHandler'
2322
import { makeTemporaryToolkitFolder } from '../../shared/filesystemUtilities'
2423
import fs from '../../shared/fs/fs'
2524
import { ZipUtil } from '../../codewhisperer/util/zipUtil'
25+
import { randomUUID } from '../../shared/crypto'
2626

2727
const filePromptWithSecurityIssues = `from flask import app
2828
@@ -95,7 +95,7 @@ describe('CodeWhisperer security scan', async function () {
9595
const projectPaths = zipUtil.getProjectPaths()
9696
const scope = CodeWhispererConstants.CodeAnalysisScope.PROJECT
9797
const zipMetadata = await zipUtil.generateZip(uri, scope)
98-
const codeScanName = generateScanName(projectPaths, scope)
98+
const codeScanName = randomUUID()
9999

100100
let artifactMap
101101
try {

0 commit comments

Comments
 (0)