Skip to content

Commit 40f6a9e

Browse files
committed
chore: add git-secrets-scan to repository
1 parent 3e228d6 commit 40f6a9e

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

.gitallowed

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# The only AWS account number allowed to be used in tests (used by git-secrets)
2+
account: '123456789012'
3+
account='123456789012'
4+
5+
# account used for cross-environment tests in addition to the one above
6+
account: '234567890123'
7+
# Account patterns used in the README
8+
account: '000000000000'
9+
account: '111111111111'
10+
account: '222222222222'
11+
account: '333333333333'
12+
13+
# used in physical names tests in @aws-cdk/core
14+
account: '012345678912'
15+
account: '012345678913'
16+
17+
# The account ID's of public facing ECR images for App Mesh Envoy
18+
# https://docs.aws.amazon.com/app-mesh/latest/userguide/envoy.html
19+
account: '772975370895'
20+
account: '856666278305'
21+
account: '840364872350'
22+
account: '422531588944'
23+
account: '924023996002'
24+
account: '919366029133' #cn-north-1
25+
account: '919830735681' #cn-northwest-1
26+
account: '909464085924' #ap-southeast-3
27+
account: '564877687649' #il-central-1
28+
29+
# The account IDs of password rotation applications of Serverless Application Repository
30+
# https://docs.aws.amazon.com/secretsmanager/latest/userguide/enable-rotation-rds.html
31+
# partition aws
32+
account: '297356227824'
33+
# partition aws-cn
34+
account: '193023089310'
35+
# partition aws-us-gov
36+
account: '023102451235'

.projen/tasks.json

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

.projenrc.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ const repoProject = new yarn.Monorepo({
211211
},
212212
},
213213
},
214+
214215
buildWorkflowOptions: {
215216
preBuildSteps: [
216217
// Need this for the init tests
@@ -237,11 +238,23 @@ repoProject.eslint = new pj.javascript.Eslint(repoProject, {
237238
fileExtensions: ['.ts', '.tsx'],
238239
lintProjenRc: false,
239240
});
241+
240242
// always lint projen files as part of the build
241243
if (repoProject.eslint?.eslintTask) {
242244
repoProject.tasks.tryFind('build')?.spawn(repoProject.eslint?.eslintTask);
243245
}
244246

247+
// always scan for git secrets before building
248+
const gitSecretsScan = repoProject.addTask('git-secrets-scan', {
249+
steps: [
250+
{
251+
exec: '/bin/bash ./projenrc/git-secrets-scan.sh',
252+
},
253+
],
254+
});
255+
256+
repoProject.tasks.tryFind('build')?.prependSpawn(gitSecretsScan);
257+
245258
new AdcPublishing(repoProject);
246259

247260
const repo = configureProject(repoProject);

package.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projenrc/git-secrets-scan.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
mkdir -p .tools
5+
[[ ! -d .tools/git-secrets ]] && {
6+
echo "============================================================================================="
7+
echo "Downloading git-secrets..."
8+
(cd .tools && git clone --depth 1 https://github.com/awslabs/git-secrets.git)
9+
}
10+
11+
# As the name implies, git-secrets heavily depends on git:
12+
#
13+
# a) the config is stored and fetched using 'git config'.
14+
# b) the search is performed using 'git grep' (other search methods don't work
15+
# properly, see https://github.com/awslabs/git-secrets/issues/66)
16+
#
17+
# When we run in a CodeBuild build, we don't have a git repo, unfortunately. So
18+
# when that's the case, 'git init' one on the spot, add all files to it (which
19+
# because of the .gitignore will exclude dependencies and generated files) and
20+
# then call 'git-secrets' as usual.
21+
git rev-parse --git-dir > /dev/null 2>&1 || {
22+
git init --quiet
23+
git add -A .
24+
}
25+
26+
# AWS config needs to be added to this repository's config
27+
.tools/git-secrets/git-secrets --register-aws
28+
29+
.tools/git-secrets/git-secrets --scan
30+
echo "git-secrets scan ok"

0 commit comments

Comments
 (0)