Skip to content

Commit a215819

Browse files
authored
Merge pull request #6438 from aws/autoMerge/feature/q-dev-execution
Merge master into feature/q-dev-execution
2 parents e06906f + 07e0ea8 commit a215819

File tree

14 files changed

+184
-78
lines changed

14 files changed

+184
-78
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- run: npm run testCompile
5858
- run: npm run lint
5959

60-
jscpd:
60+
lint-duplicate-code:
6161
needs: lint-commits
6262
if: ${{ github.event_name == 'pull_request'}}
6363
runs-on: ubuntu-latest
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
nodejs: 16
7+
8+
commands:
9+
- apt update
10+
- apt install -y wget gpg
11+
- curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
12+
- install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
13+
- sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
14+
- apt update
15+
- apt install -y code
16+
17+
pre_build:
18+
commands:
19+
# Check for implicit env vars passed from the release pipeline.
20+
- test -n "${TARGET_EXTENSION}"
21+
22+
build:
23+
commands:
24+
- VERSION=$(node -e "console.log(require('./packages/${TARGET_EXTENSION}/package.json').version);")
25+
# get extension name
26+
- |
27+
if [ "${TARGET_EXTENSION}" = "amazonq" ]; then
28+
extension_name="amazonwebservices.amazon-q-vscode"
29+
elif [ "${TARGET_EXTENSION}" = "toolkit" ]; then
30+
extension_name="amazonwebservices.aws-toolkit-vscode"
31+
else
32+
echo checkmarketplace: "Unknown TARGET_EXTENSION: ${TARGET_EXTENSION}"
33+
exit 1
34+
fi
35+
# keep reinstalling the extension until the desired version is updated. Otherwise fail on codebuild timeout (1 hour).
36+
- |
37+
while true; do
38+
code --uninstall-extension "${extension_name}" --no-sandbox --user-data-dir /tmp/vscode
39+
code --install-extension ${extension_name} --no-sandbox --user-data-dir /tmp/vscode
40+
cur_version=$(code --list-extensions --show-versions --no-sandbox --user-data-dir /tmp/vscode | grep ${extension_name} | cut -d'@' -f2)
41+
if [ "${cur_version}" = "${VERSION}" ]; then
42+
echo "checkmarketplace: Extension ${extension_name} is updated to version '${cur_version}.'"
43+
break
44+
else
45+
echo "checkmarketplace: Current version '${cur_version}' does not match expected version '${VERSION}'. Retrying..."
46+
fi
47+
sleep 120 # Wait for 2 minutes before retrying
48+
done

package-lock.json

Lines changed: 40 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"mergeReports": "ts-node ./scripts/mergeReports.ts"
4141
},
4242
"devDependencies": {
43-
"@aws-toolkits/telemetry": "^1.0.293",
43+
"@aws-toolkits/telemetry": "^1.0.295",
4444
"@playwright/browser-chromium": "^1.43.1",
4545
"@stylistic/eslint-plugin": "^2.11.0",
4646
"@types/he": "^1.2.3",

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,31 @@ describe('securityScanHandler', function () {
131131
assert.equal(aggregatedCodeScanIssueList.length, 2)
132132
assert.equal(aggregatedCodeScanIssueList[0].issues.length, 3)
133133
})
134+
135+
it('should set autoDetected based on scope', async function () {
136+
mockClient.listCodeScanFindings.resolves(
137+
buildMockListCodeScanFindingsResponse(JSON.stringify([buildRawCodeScanIssue()]))
138+
)
139+
for (const [scope, expectedValue] of [
140+
[CodeAnalysisScope.FILE_AUTO, true],
141+
[CodeAnalysisScope.FILE_ON_DEMAND, false],
142+
[CodeAnalysisScope.PROJECT, false],
143+
] as [CodeAnalysisScope, boolean][]) {
144+
const aggregatedCodeScanIssueList = await listScanResults(
145+
mockClient,
146+
'jobId',
147+
'codeScanFindingsSchema',
148+
['projectPath'],
149+
scope,
150+
undefined
151+
)
152+
assert.ok(
153+
aggregatedCodeScanIssueList.every((item) =>
154+
item.issues.every((issue) => issue.autoDetected === expectedValue)
155+
)
156+
)
157+
}
158+
})
134159
})
135160

136161
describe('mapToAggregatedList', () => {

packages/core/package.nls.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
2121
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source code and template.yaml files",
2222
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
23-
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
24-
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.\n * `ec2RemoteConnect` - Allows interfacing with EC2 instances with options to start, stop, and establish remote connections. Remote connections are done over SSM and can be through a terminal or a remote VSCode window.",
23+
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
24+
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.",
2525
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
2626
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
2727
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",
@@ -296,6 +296,7 @@
296296
"AWS.codewhisperer.customization.notification.new_customizations.learn_more": "Learn More",
297297
"AWS.amazonq.title": "Amazon Q",
298298
"AWS.amazonq.chat": "Chat",
299+
"AWS.amazonq.chat.workspacecontext.enable.message": "Amazon Q: Workspace index is now enabled. You can disable it from Amazon Q settings.",
299300
"AWS.amazonq.security": "Code Issues",
300301
"AWS.amazonq.login": "Login",
301302
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
@@ -411,6 +412,7 @@
411412
"AWS.amazonq.doc.pillText.reject": "Reject",
412413
"AWS.amazonq.doc.pillText.makeChanges": "Make changes",
413414
"AWS.amazonq.inline.invokeChat": "Inline chat",
415+
"AWS.amazonq.opensettings:": "Open settings",
414416
"AWS.toolkit.lambda.walkthrough.quickpickTitle": "Application Builder Walkthrough",
415417
"AWS.toolkit.lambda.walkthrough.title": "Get started building your application",
416418
"AWS.toolkit.lambda.walkthrough.description": "Your quick guide to build an application visually, iterate locally, and deploy to the cloud!",

packages/core/src/awsexplorer/regionNode.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { getEcsRootNode } from '../awsService/ecs/model'
3030
import { compareTreeItems, TreeShim } from '../shared/treeview/utils'
3131
import { Ec2ParentNode } from '../awsService/ec2/explorer/ec2ParentNode'
3232
import { Ec2Client } from '../shared/clients/ec2Client'
33-
import { Experiments } from '../shared/settings'
3433

3534
interface ServiceNode {
3635
allRegions?: boolean
@@ -64,7 +63,6 @@ const serviceCandidates: ServiceNode[] = [
6463
},
6564
{
6665
serviceId: 'ec2',
67-
when: () => Experiments.instance.isExperimentEnabled('ec2RemoteConnect'),
6866
createFn: (regionCode: string, partitionId: string) =>
6967
new Ec2ParentNode(regionCode, partitionId, new Ec2Client(regionCode)),
7068
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ export const applySecurityFix = Commands.declare(
447447
result: 'Succeeded',
448448
credentialStartUrl: AuthUtil.instance.startUrl,
449449
codeFixAction: 'applyFix',
450+
autoDetected: targetIssue.autoDetected,
451+
codewhispererCodeScanJobId: targetIssue.scanJobId,
450452
}
451453
let languageId = undefined
452454
try {
@@ -711,6 +713,7 @@ export const generateFix = Commands.declare(
711713
} else {
712714
hasSuggestedFix = suggestedFix !== undefined
713715
}
716+
telemetry.record({ includesFix: hasSuggestedFix })
714717
const updatedIssue: CodeScanIssue = {
715718
...targetIssue,
716719
fixJobId: jobId,
@@ -755,6 +758,8 @@ export const generateFix = Commands.declare(
755758
findingId: targetIssue.findingId,
756759
ruleId: targetIssue.ruleId,
757760
variant: refresh ? 'refresh' : undefined,
761+
autoDetected: targetIssue.autoDetected,
762+
codewhispererCodeScanJobId: targetIssue.scanJobId,
758763
})
759764
}
760765
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ export interface CodeScanIssue {
487487
scanJobId: string
488488
language: string
489489
fixJobId?: string
490+
autoDetected?: boolean
490491
}
491492

492493
export interface AggregatedCodeScanIssue {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function listScanResults(
8383
if (existsSync(filePath) && statSync(filePath).isFile()) {
8484
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
8585
filePath: filePath,
86-
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId)),
86+
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId, scope)),
8787
}
8888
aggregatedCodeScanIssueList.push(aggregatedCodeScanIssue)
8989
}
@@ -92,7 +92,7 @@ export async function listScanResults(
9292
if (existsSync(maybeAbsolutePath) && statSync(maybeAbsolutePath).isFile()) {
9393
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
9494
filePath: maybeAbsolutePath,
95-
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId)),
95+
issues: issues.map((issue) => mapRawToCodeScanIssue(issue, editor, jobId, scope)),
9696
}
9797
aggregatedCodeScanIssueList.push(aggregatedCodeScanIssue)
9898
}
@@ -103,7 +103,8 @@ export async function listScanResults(
103103
function mapRawToCodeScanIssue(
104104
issue: RawCodeScanIssue,
105105
editor: vscode.TextEditor | undefined,
106-
jobId: string
106+
jobId: string,
107+
scope: CodeWhispererConstants.CodeAnalysisScope
107108
): CodeScanIssue {
108109
const isIssueTitleIgnored = CodeWhispererSettings.instance.getIgnoredSecurityIssues().includes(issue.title)
109110
const isSingleIssueIgnored =
@@ -130,6 +131,7 @@ function mapRawToCodeScanIssue(
130131
visible: !isIssueTitleIgnored && !isSingleIssueIgnored,
131132
scanJobId: jobId,
132133
language,
134+
autoDetected: scope === CodeWhispererConstants.CodeAnalysisScope.FILE_AUTO,
133135
}
134136
}
135137

0 commit comments

Comments
 (0)