File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
GAR Prerequisites:
4
4
1 . ** REGISTRY** : Full registry path for GAR
5
- 2 . ** SA_EMAIL** : [ Service Account Email] ( ../res/gcp-service-account.png )
6
- 3 . Service Account Json: File containing the creds
7
- 4 . ** IMGSPEC** : Regular expression for images to scan/upload-results. E.g. ` .*:latest ` => scan all the images having ` latest ` tag. Sample image name:` us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem/nginx:foobar `
5
+ 1 . ** Service Account Json** : [ File containing the creds] ( ../res/gcp-service-account.png )
6
+ 1 . ** IMGSPEC** : Regular expression for images to scan/upload-results. E.g. ` .*:latest ` => scan all the images having ` latest ` tag. Sample image name:` us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem/nginx:foobar `
8
7
9
8
AccuKnox Prerequisites:
10
9
1 . ** LABEL** : [ AccuKnox Label] ( https://help.accuknox.com/how-to/how-to-create-labels/ )
@@ -16,7 +15,6 @@ Scan images with tags `foobar`.
16
15
``` bash
17
16
docker run -eIMGSPEC=" .*:foobar$" \
18
17
-eREGISTRY=us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem \
19
- -e" SA_EMAIL=<service-account-email>" \
20
18
-eLABEL=labeltmp \
21
19
-eTENANT=4093 \
22
20
-eTOKEN=< get token> \
@@ -33,7 +31,6 @@ pipeline {
33
31
environment {
34
32
SA_FILE = credentials('SA_FILE')
35
33
TOKEN = credentials('TOKEN')
36
- SA_EMAIL = credentials('SA_EMAIL')
37
34
}
38
35
stages {
39
36
stage('Accuknox') {
@@ -44,7 +41,6 @@ pipeline {
44
41
sh '''
45
42
docker run -e IMGSPEC=".*:foobar$" \
46
43
-e REGISTRY=us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem \
47
-
48
44
-e LABEL=mylabel \
49
45
-e TENANT=4093 \
50
46
-e TOKEN=$TOKEN \
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
3
SA_JSON=" $( pwd) /service_account.json"
4
- [[ " $SA_EMAIL " == " " ]] && echo " SA_EMAIL / ServiceAccount Email not provided" && exit 1
5
4
[[ " $AKURL " == " " ]] && echo " AKURL / Accuknox endpoint is not set" && exit 1
6
5
[[ " $TENANT " == " " ]] && echo " TENANT / Tenant id is not set" && exit 1
7
6
[[ " $LABEL " == " " ]] && echo " LABEL / Labels are not set" && exit 1
@@ -11,15 +10,14 @@ SA_JSON="$(pwd)/service_account.json"
11
10
12
11
export GOOGLE_APPLICATION_CREDENTIALS=$SA_JSON
13
12
14
- # REGISTRY=${REGISTRY:-us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem}
15
-
16
- gcloud auth activate-service-account $SA_EMAIL --key-file=$SA_JSON
13
+ gcloud auth activate-service-account --key-file=$SA_JSON
14
+ [[ $? -ne 0 ]] && echo " gcloud auth failed ret=$? " && exit 2
17
15
18
16
for img in ` gcloud artifacts docker images list " $REGISTRY " --include-tags --format=json | jq -r ' .[] | "\(.package):\(.tags[])"' 2> /dev/null` ; do
19
17
[[ ! $img =~ $IMGSPEC ]] && echo -en " \nskipping image [$img ] ...\n" && continue
20
18
echo -en " \nscanning $img ...\n"
21
19
rm -f report.json 2> /dev/null
22
20
trivy image $img --format json --timeout 3600s -o report.json > report.log 2>&1
23
- [[ ! -f " report.json" ]] && echo " image scanning failed $img " && continue
21
+ [[ ! -f " report.json" ]] && echo " image scanning failed $img " && cat report.log && continue
24
22
curl -L -X POST " https://$AKURL /api/v1/artifact/?tenant_id=$TENANT &data_type=TR&label_id=$LABEL &save_to_s3=false" -H " Tenant-Id: $TENANT " -H " Authorization: Bearer $TOKEN " --form ' file=@"./report.json"'
25
23
done
You can’t perform that action at this time.
0 commit comments