Skip to content

Commit 997dab3

Browse files
authored
refactor(main): wip (#134)
* refactor(main): wip * simplify * refactor unused code and features * fix(workkflows): go version * fix(workkflows): go version * fix(workkflows): check latest * fix(workflows): cache false * fix(workflows): use single * fix(picante): remove vipers * fix netpol * fix github orgs * fix(picante): config github orgs * update(picante): charts yml * add(attestation): rekor index * fix(charts): config type for github orgs should be string
1 parent a04b8a9 commit 997dab3

23 files changed

+223
-447
lines changed

.env.sample

-2
This file was deleted.

.github/dependabot.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7-
open-pull-requests-limit: 5
87
- package-ecosystem: "github-actions"
98
directory: "/"
109
schedule:
1110
interval: "weekly"
12-
open-pull-requests-limit: 5
1311
- package-ecosystem: "docker"
1412
directory: "/"
1513
schedule:
16-
interval: "weekly"
17-
open-pull-requests-limit: 5
14+
interval: "weekly"

.github/workflows/main.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- uses: actions/setup-go@v5
2020
with:
21-
go-version: ">=1.22.1"
21+
go-version: '>=1.22.1'
2222
cache-dependency-path: ./go.sum
2323
- run: make test
2424

.github/workflows/pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-go@v5
2121
with:
22-
go-version: ">=1.22.1"
22+
go-version: '>=1.22.1'
2323
cache-dependency-path: ./go.sum
2424
- run: make test
2525

@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- name: Dependabot metadata
3232
id: dependabot-metadata
33-
uses: dependabot/fetch-metadata@v1.6.0
33+
uses: dependabot/fetch-metadata@v1
3434
with:
3535
github-token: "${{ secrets.GITHUB_TOKEN }}"
3636
- name: Approve a PR

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ COPY --from=builder /bin/picante /app/picante
1717
RUN apk add --no-cache git
1818

1919
ENTRYPOINT ["/app/picante"]
20-

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ generate-mocks:
2929
go run github.com/vektra/mockery/v2 --inpackage --case snake --srcpkg ./internal/attestation --name Verifier
3030

3131
check:
32+
go version
3233
go run honnef.co/go/tools/cmd/staticcheck@latest ./...
3334
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
3435
go run golang.org/x/tools/cmd/deadcode@latest -filter "internal/test/client.go" -filter "internal/test/test.go" -test ./...

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
### Setup
66

7-
To run in a local k8s cluster
7+
Pre-requisites:
88

9-
* Add a [picante config](hack/picante-config-example.yaml) in root of project starting with
10-
name `picante`
9+
Copy the `.env.example` file from [here](hack/.env.sample)
10+
to the root of the project and rename it to `.env` and fill in the required environment variables.
11+
Example is listed in the `.env.example` file.
12+
13+
To start the development environment, run the following command;
1114

1215
```bash
1316
make dtrack-up
@@ -18,3 +21,12 @@ wait for dp to be ready and run;
1821
```bash
1922
make local
2023
```
24+
25+
Navigate to the cluster you are interested to work with, Picante will now start to fetch data from the cluster.
26+
And fill the local database with the data.
27+
28+
You can now access the instance of Dependant Track by navigating to `http://localhost:9010` in your browser.
29+
If it is fresh start, you will need to create a user to be able to login. Navigate to `http://localhost:9010`
30+
Login with admin user and password `admin` and create a new password matching the password in your `.env` file.
31+
Navigate to Administration -> Access Management -> Teams -> Administrators and click the plus sign to add api_key to the team.
32+
Picante will now be able to fetch data from the cluster.

charts/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: picante
33
sources:
44
- https://github.com/nais/picante/tree/main/charts
5-
description: Informer to update salsa storage with attestation data
5+
description: Informer to update salsa storage (dependency-track) with attestation metadata (sbom)
66
type: application
77
version: 0.2.5

charts/Feature.yaml

+6-25
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,22 @@ values:
2121
computed:
2222
template: '"{{.Env.name}}"'
2323
config.github.organizations:
24-
description: Required GitHub organizations to verify image attestations
24+
description: Required GitHub organizations to verify image attestations, a comma seperated list
2525
displayName: GitHub organization(s)
2626
computed:
2727
template: |
2828
{{ if or (eq .Tenant.Name "nav") (eq .Tenant.Name "dev-nais") }}
29-
- navikt
30-
- nais
29+
"nais,navikt"
3130
{{ else }}
32-
- nais
33-
- "{{.Tenant.Name}}"
31+
"nais,{{.Tenant.Name}}"
3432
{{ end }}
3533
config:
36-
type: string_array
37-
config.identities:
38-
displayName: Preconfigured signature sa Identities
39-
computed:
40-
template: |
41-
- issuer: "https://accounts.google.com"
42-
subjectRegExp: ".*@nais-io.iam.gserviceaccount.com"
43-
config.storage.password:
34+
type: string
35+
config.dependencytrack.password:
4436
displayName: dependencytrack API password
4537
computed:
4638
template: '"{{.Management.picante_dependencytrack_password}}"'
47-
config.storage.api:
39+
config.dependencytrack.api:
4840
displayName: dependencytrack API endpoint
4941
computed:
5042
template: |
@@ -53,17 +45,6 @@ values:
5345
{{ else }}
5446
"https://dependencytrack-backend.{{.Tenant.Name}}.cloud.nais.io"
5547
{{ end }}
56-
config.teamIdentity:
57-
displayName: Preconfigured team identity
58-
computed:
59-
template: |
60-
{{ if eq .Tenant.Name "nav" }}
61-
issuer: "https://accounts.google.com"
62-
domain: "nais-management-233d.iam.gserviceaccount.com"
63-
{{ else }}
64-
issuer: "https://accounts.google.com"
65-
domain: "{{.Management.project_id}}.iam.gserviceaccount.com"
66-
{{ end }}
6748
dockerconfigjson:
6849
displayName: Docker config json
6950
required: true

charts/templates/deployment.yaml

+29-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
env:
3131
- name: DOCKER_CONFIG
3232
value: /etc/docker-credentials
33-
{{- if .Values.webproxy }}
33+
{{- if .Values.webproxy }}
3434
- name: HTTP_PROXY
3535
value: http://webproxy.nais:8088
3636
- name: http_proxy
@@ -43,7 +43,33 @@ spec:
4343
value: localhost,127.0.0.1,10.254.0.1,.local,.adeo.no,.nav.no,.aetat.no,.devillo.no,.oera.no,.nais.io,.aivencloud.com,.intern.dev.nav.no
4444
- name: no_proxy
4545
value: localhost,127.0.0.1,10.254.0.1,.local,.adeo.no,.nav.no,.aetat.no,.devillo.no,.oera.no,.nais.io,.aivencloud.com,.intern.dev.nav.no
46-
{{- end }}
46+
{{- end }}
47+
- name: CLUSTER
48+
value: {{ .Values.config.cluster }}
49+
- name: LOG_LEVEL
50+
value: {{ .Values.config.logLevel }}
51+
- name: GITHUB_ORGANIZATIONS
52+
value: {{ .Values.config.github.organizations }}
53+
- name: DEPENDENCYTRACK_TEAM
54+
value: {{ .Values.config.dependencytrack.team }}
55+
- name: DEPENDENCYTRACK_API
56+
value: {{ .Values.config.dependencytrack.api }}
57+
- name: DEPENDENCYTRACK_USERNAME
58+
valueFrom:
59+
secretKeyRef:
60+
name: {{ include "picante.fullname" . }}
61+
key: dependencytrack_username
62+
- name: DEPENDENCYTRACK_PASSWORD
63+
valueFrom:
64+
secretKeyRef:
65+
name: {{ include "picante.fullname" . }}
66+
key: dependencytrack_password
67+
- name: COSIGN_KEY_REF
68+
valueFrom:
69+
secretKeyRef:
70+
name: {{ include "picante.fullname" . }}
71+
key: cosign_key_ref
72+
4773
securityContext:
4874
runAsNonRoot: true
4975
runAsUser: 1000
@@ -70,7 +96,7 @@ spec:
7096
{{- toYaml .Values.resources | nindent 12 }}
7197
volumes:
7298
- name: writable-tmp
73-
emptyDir: {}
99+
emptyDir: { }
74100
- name: config-volume
75101
configMap:
76102
name: {{ include "picante.fullname" . }}

charts/templates/netpol.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ spec:
4242
{{- range $key, $value := .Values.fqdns }}
4343
- {{ $value }}
4444
{{- end }}
45-
{{- if hasPrefix "https" .Values.config.storage.api }}
46-
- {{ get (urlParse .Values.config.storage.api) "host" }}
45+
{{- if hasPrefix "https" .Values.config.dependencytrack.api }}
46+
- {{ get (urlParse .Values.config.dependencytrack.api) "host" }}
4747
{{- end }}
4848
podSelector:
4949
matchLabels:

charts/templates/secrets.yaml

+3-18
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ metadata:
66
labels:
77
{{- include "picante.labels" . | nindent 4 }}
88
stringData:
9-
picante.yaml: |
10-
features:
11-
{{- if .Values.config.features.enabled }}
12-
label-selectors:
13-
{{- .Values.config.features.labelSelectors | toYaml | nindent 8 }}
14-
{{- end }}
15-
cosign:
16-
{{- .Values.config.cosign | toYaml | nindent 6 }}
17-
storage:
18-
{{- .Values.config.storage | toYaml | nindent 6 }}
19-
identities:
20-
{{- .Values.config.identities | toYaml | nindent 6 }}
21-
github:
22-
{{- .Values.config.github | toYaml | nindent 6 }}
23-
teamIdentity:
24-
{{- .Values.config.teamIdentity | toYaml | nindent 6 }}
25-
cluster: {{ .Values.config.cluster }}
26-
log-level: {{ .Values.logLevel }}
9+
dependencytrack_username: "{{ .Values.config.dependencytrack.username }}"
10+
dependencytrack_password: "{{ .Values.config.dependencytrack.password }}"
11+
cosign_key_ref: "{{ .Values.config.cosign.keyRef }}"

charts/values.yaml

+3-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ image:
55
name: picante
66
tag: 20230414-090558-6aaa3f2
77

8-
logLevel: info
9-
108
team: nais
119

1210
webproxy: false
@@ -27,25 +25,17 @@ fqdns:
2725
- europe-north1-docker.pkg.dev
2826

2927
config:
30-
features:
31-
enabled: false
32-
labelSelectors:
33-
name: nais.io/salsa-verify-attestation
34-
value: "true"
28+
logLevel: info
3529
cluster: test
3630
cosign:
3731
keyRef:
38-
storage:
32+
dependencytrack:
3933
api: http://dependencytrack-backend:8080
4034
username: picante
4135
password:
4236
team: Administrators
43-
identities: [ ]
44-
teamIdentity:
45-
issuer:
46-
domain:
4737
github:
48-
organizations: [ ]
38+
organizations:
4939

5040
kms:
5141
pubKey: |

0 commit comments

Comments
 (0)