Skip to content

Commit 044c4ec

Browse files
authored
Collect jobs on finish and improved error handling (#9)
* Collect jobs on finish and improved error handling * Update go version in ci.yaml * tidy mods * add inline_scanning_extra_params options
1 parent 3d4e9bc commit 044c4ec

File tree

11 files changed

+400
-198
lines changed

11 files changed

+400
-198
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v2
1919
with:
20-
go-version: ^1.14
20+
go-version: ^1.16
2121

2222
- name: Check out code
2323
uses: actions/checkout@v2

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
.PHONY: test
2+
13
test:
24
ginkgo -randomizeAllSpecs -randomizeSuites -failOnPending -trace -race -progress -cover -r
35

46
docker:
57
docker build -f build/Dockerfile -t sysdiglabs/harbor-scanner-sysdig-secure .
8+
9+
push:
610
docker push sysdiglabs/harbor-scanner-sysdig-secure

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14 as builder
1+
FROM golang:1.16 as builder
22
WORKDIR /harbor-scanner-sysdig-secure
33
COPY go.mod go.sum ./
44
COPY . .

cmd/harbor-scanner-sysdig-secure/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func configure() error {
4747
pflag.Bool("inline_scanning", false, "Use Inline Scanning Adapter")
4848
pflag.String("namespace_name", "", "Namespace where inline scanning jobs are spawned")
4949
pflag.String("secret_name", "", "Secret which keeps the inline scanning secrets ")
50+
pflag.String("inline_scanning_extra_params", "", "Extra parameters to provide to inline-scanner")
5051

5152
pflag.VisitAll(func(flag *pflag.Flag) { viper.BindPFlag(flag.Name, flag) })
5253

@@ -77,13 +78,16 @@ func getAdapter() scanner.Adapter {
7778
if err != nil {
7879
log.Fatal(err)
7980
}
81+
8082
return scanner.NewInlineAdapter(
8183
client,
8284
clientset,
8385
viper.GetString("secure_url"),
8486
viper.GetString("namespace_name"),
8587
viper.GetString("secret_name"),
86-
viper.GetBool("verify_ssl"))
88+
viper.GetString("inline_scanning_extra_params"),
89+
viper.GetBool("verify_ssl"),
90+
log.StandardLogger())
8791
}
8892

8993
log.Info("Using backend-scanning adapter")

docs/install.md

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,67 +46,22 @@ kubectl --namespace harbor-scanner-sysdig-secure port-forward $POD_NAME 8080:80
4646
And that's it. The new scanner adapter is deployed. Now is time to tell Harbor
4747
to use it, and you can find [how to configure Harbor to use Sysdig Secure Scanner Adapter](#configuring-harbor-to-use-sysdig-secure-scanner-adapter) a few lines below.
4848

49-
### Using Inline Scanning instead of Backend Scanning
49+
### Using Backend Scanning instead of Inline Scanning
5050

51-
The Inline Scanning requires a bit more of configuration. We will use a file
52-
to keep these settings:
51+
This mode is not recommended and it is supported only for legacy purposes.
52+
53+
You will need to disable inline scan by setting `inlineScanning.enabled: false` in the values.yaml:
5354

5455
```yaml
5556
sysdig:
5657
secure:
5758
apiToken: XXX
5859

5960
inlineScanning:
60-
enabled: true
61-
harbor:
62-
robotAccount:
63-
name: robotAccount
64-
password: XXX
65-
CA: |
66-
-----BEGIN CERTIFICATE-----
67-
...
68-
-----END CERTIFICATE-----
69-
```
70-
71-
You already know [how to get the Sysdig Secure API Token](#obtaining-the-sysdig-secure-api-token)
72-
so that we can go to next steps.
73-
74-
Next step is about the robot account. As long as this mode uses `docker` command
75-
under the hoods to perform the scanning, we need to authenticate against
76-
the registry using `docker`, and we will do it using a robot acount. Harbor
77-
folks did a pretty good job documenting [how to create a robot account](https://goharbor.io/docs/1.10/working-with-projects/project-configuration/create-robot-accounts/).
78-
Once you created the account, be sure you fill the values under
79-
`inlineScanning.harbor.robotAccount` key.
80-
81-
Next step is to get and configure the CA certificate that Harbor uses. Again,
82-
Harbor folks did a great job documenting [how to download the CA certificate](https://goharbor.io/docs/1.10/working-with-projects/working-with-images/pulling-pushing-images/#download-the-harbor-certificate).
83-
Once you have the certificate, ensure is under the `inlineScanning.harbor.CA` key.
84-
Pay attention to the `|` pipe symbol because we need to keep it raw.
85-
86-
Finally, next step is to deploy the scanner adapter:
87-
88-
```
89-
$ helm repo add sysdiglabs https://sysdiglabs.github.io/charts
90-
"sysdiglabs" has been added to your repositories
91-
92-
$ kubectl create namespace harbor-scanner-sysdig-secure
93-
namespace/harbor-scanner-sysdig-secure created
94-
95-
$ helm -n harbor-scanner-sysdig-secure install harbor-scanner-sysdig-secure -f values.yaml sysdiglabs/harbor-scanner-sysdig-secure
96-
NAME: harbor-scanner-sysdig-secure
97-
LAST DEPLOYED: Tue Jun 9 13:38:12 2020
98-
NAMESPACE: harbor-scanner-sysdig-secure
99-
STATUS: deployed
100-
REVISION: 1
101-
NOTES:
102-
1. Get the application URL by running these commands:
103-
104-
export POD_NAME=$(kubectl get pods --namespace harbor-scanner-sysdig-secure -l "app.kubernetes.io/name=harbor-scanner-sysdig-secure,app.kubernetes.io/instance=harbor-scanner-sysdig-secure" -o jsonpath="{.items[0].metadata.name}")
105-
echo "Visit http://127.0.0.1:8080 to use your application"
106-
kubectl --namespace harbor-scanner-sysdig-secure port-forward $POD_NAME 8080:80
61+
enabled: false
10762
```
10863
109-
And once we deployed the scanner adapter, is time to tell Harbor to use it.
64+
You already know [how to get the Sysdig Secure API Token](#obtaining-the-sysdig-secure-api-token).
11065
11166
## Configuring Harbor to use Sysdig Secure Scanner Adapter
11267

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
module github.com/sysdiglabs/harbor-scanner-sysdig-secure
22

3-
go 1.14
3+
go 1.16
44

55
require (
66
github.com/golang/mock v1.4.3
77
github.com/gorilla/handlers v1.4.2
88
github.com/gorilla/mux v1.7.4
9-
github.com/onsi/ginkgo v1.12.0
10-
github.com/onsi/gomega v1.7.1
9+
github.com/onsi/ginkgo v1.16.4
10+
github.com/onsi/gomega v1.10.1
1111
github.com/sirupsen/logrus v1.5.0
1212
github.com/spf13/pflag v1.0.5
1313
github.com/spf13/viper v1.7.0
14-
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c // indirect
15-
k8s.io/api v0.18.2
16-
k8s.io/apimachinery v0.18.2
17-
k8s.io/client-go v0.18.2
14+
k8s.io/api v0.19.13
15+
k8s.io/apimachinery v0.19.13
16+
k8s.io/client-go v0.19.13
1817
)

0 commit comments

Comments
 (0)