Skip to content

Commit 2ca8f7c

Browse files
authored
ci: run-as unprivileged user #3565
ref 59a0a83 ref f53186e
1 parent 59a0a83 commit 2ca8f7c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

buildspec/linuxTests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ phases:
1212
run-as: root
1313
runtime-versions:
1414
nodejs: 16
15-
1615
commands:
1716
# Without this, "Unable to locate package libatk1.0-0".
1817
- '>/dev/null apt-get -yqq update'
1918
# Dependencies for running vscode.
2019
- '>/dev/null apt-get -yqq install libatk1.0-0 libgtk-3-dev libxss1 xvfb libasound2 libasound2-plugins'
21-
#
2220
# Prepare env for unprivileged user.
23-
#
2421
- |
2522
mkdir -p ~codebuild-user
2623
chown -R codebuild-user:codebuild-user /tmp ~codebuild-user .

buildspec/packageTestVsix.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: 0.2
22

3+
# Run unprivileged for most phases (except those marked "run-as: root").
4+
run-as: codebuild-user
5+
36
env:
47
variables:
58
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/'
@@ -8,11 +11,21 @@ env:
811

912
phases:
1013
install:
14+
run-as: root
1115
runtime-versions:
1216
nodejs: 16
17+
commands:
18+
# Prepare env for unprivileged user.
19+
- |
20+
mkdir -p ~codebuild-user
21+
chown -R codebuild-user:codebuild-user /tmp ~codebuild-user .
22+
chmod +x ~codebuild-user
23+
ls -ld ~codebuild-user
1324
1425
pre_build:
1526
commands:
27+
# CodeBuild ignores env.variables.HOME, so do it manually here :(
28+
- export HOME=/home/codebuild-user
1629
# If present, log into CodeArtifact. Provides a nice safety net in case NPM is down.
1730
# Should only affect tests run through IDEs team-hosted CodeBuild.
1831
- |
@@ -23,11 +36,12 @@ phases:
2336
echo "CodeArtifact connection failed. Falling back to npm"
2437
fi
2538
fi
26-
# --unsafe-perm is needed because CodeBuild/CodePipeline runs as root
27-
- npm ci --unsafe-perm
39+
- npm ci
2840

2941
build:
3042
commands:
43+
# CodeBuild ignores env.variables.HOME, so do it manually here :(
44+
- export HOME=/home/codebuild-user
3145
# Generate CHANGELOG.md
3246
- npm run createRelease
3347
- npm run generateNonCodeFiles

0 commit comments

Comments
 (0)