Skip to content

Commit 0e1fa49

Browse files
committed
removed SA_EMAIL
Signed-off-by: Rahul Jadhav <[email protected]>
1 parent 84c91f5 commit 0e1fa49

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

imgscan/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
GAR Prerequisites:
44
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`
87

98
AccuKnox Prerequisites:
109
1. **LABEL**: [AccuKnox Label](https://help.accuknox.com/how-to/how-to-create-labels/)
@@ -16,7 +15,6 @@ Scan images with tags `foobar`.
1615
```bash
1716
docker run -eIMGSPEC=".*:foobar$" \
1817
-eREGISTRY=us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem \
19-
-e"SA_EMAIL=<service-account-email>" \
2018
-eLABEL=labeltmp \
2119
-eTENANT=4093 \
2220
-eTOKEN=<get token> \
@@ -33,7 +31,6 @@ pipeline {
3331
environment {
3432
SA_FILE = credentials('SA_FILE')
3533
TOKEN = credentials('TOKEN')
36-
SA_EMAIL = credentials('SA_EMAIL')
3734
}
3835
stages {
3936
stage('Accuknox') {
@@ -44,7 +41,6 @@ pipeline {
4441
sh '''
4542
docker run -e IMGSPEC=".*:foobar$" \
4643
-e REGISTRY=us-east1-docker.pkg.dev/kube-airgapped/accuknox-onprem \
47-
4844
-e LABEL=mylabel \
4945
-e TENANT=4093 \
5046
-e TOKEN=$TOKEN \

imgscan/imagescan.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

33
SA_JSON="$(pwd)/service_account.json"
4-
[[ "$SA_EMAIL" == "" ]] && echo "SA_EMAIL / ServiceAccount Email not provided" && exit 1
54
[[ "$AKURL" == "" ]] && echo "AKURL / Accuknox endpoint is not set" && exit 1
65
[[ "$TENANT" == "" ]] && echo "TENANT / Tenant id is not set" && exit 1
76
[[ "$LABEL" == "" ]] && echo "LABEL / Labels are not set" && exit 1
@@ -11,15 +10,14 @@ SA_JSON="$(pwd)/service_account.json"
1110

1211
export GOOGLE_APPLICATION_CREDENTIALS=$SA_JSON
1312

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
1715

1816
for img in `gcloud artifacts docker images list "$REGISTRY" --include-tags --format=json | jq -r '.[] | "\(.package):\(.tags[])"' 2>/dev/null`; do
1917
[[ ! $img =~ $IMGSPEC ]] && echo -en "\nskipping image [$img] ...\n" && continue
2018
echo -en "\nscanning $img ...\n"
2119
rm -f report.json 2>/dev/null
2220
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
2422
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"'
2523
done

0 commit comments

Comments
 (0)