Skip to content

Commit fd56a80

Browse files
authored
Merge pull request #16 from kubewarden/artifacthub
feat: Update artifacthub-pkg.yml automatically from now on
2 parents 33c6e59 + 07dc56e commit fd56a80

File tree

7 files changed

+82
-118
lines changed

7 files changed

+82
-118
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ on:
22
push:
33
branches:
44
- main
5-
- master
65
tags:
76
- 'v*'
87

@@ -12,19 +11,18 @@ jobs:
1211

1312
test:
1413
name: run tests and linters
15-
uses: kubewarden/github-actions/.github/workflows/reusable-test-policy-rust.yml@v1
14+
uses: kubewarden/github-actions/.github/workflows/reusable-test-policy-rust.yml@v3.1.0
1615

1716
release:
1817
needs: test
1918
permissions:
20-
# Required to create GH release
19+
# Required to create GH releases
2120
contents: write
22-
# Required to push to ghcr.io
21+
# Required to push to GHCR
2322
packages: write
2423
# Required by cosign keyless signing
2524
id-token: write
2625

27-
uses: kubewarden/github-actions/.github/workflows/reusable-release-policy-rust.yml@v1
26+
uses: kubewarden/github-actions/.github/workflows/reusable-release-policy-rust.yml@v3.1.0
2827
with:
29-
input-wasm: env_variable_secrets_scanner_policy
3028
oci-target: ghcr.io/kubewarden/policies/env-variable-secrets-scanner

.github/workflows/test.yml

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,6 @@
11
on: [push, pull_request]
22
name: Continuous integration
33
jobs:
4-
check:
5-
name: Check
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v3
9-
- uses: actions-rs/toolchain@v1
10-
with:
11-
profile: minimal
12-
toolchain: stable
13-
override: true
14-
- uses: actions-rs/cargo@v1
15-
with:
16-
command: check
174
test:
18-
name: Test Suite
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v3
22-
- uses: actions-rs/toolchain@v1
23-
with:
24-
profile: minimal
25-
toolchain: stable
26-
override: true
27-
- uses: actions-rs/cargo@v1
28-
with:
29-
command: test
30-
fmt:
31-
name: Rustfmt
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v3
35-
- uses: actions-rs/toolchain@v1
36-
with:
37-
profile: minimal
38-
toolchain: stable
39-
override: true
40-
- run: rustup component add rustfmt
41-
- uses: actions-rs/cargo@v1
42-
with:
43-
command: fmt
44-
args: --all -- --check
45-
clippy:
46-
name: Clippy
47-
runs-on: ubuntu-latest
48-
steps:
49-
- uses: actions/checkout@v3
50-
- uses: actions-rs/toolchain@v1
51-
with:
52-
profile: minimal
53-
toolchain: stable
54-
override: true
55-
- run: rustup component add clippy
56-
- uses: actions-rs/cargo@v1
57-
with:
58-
command: clippy
59-
args: -- -D warnings
5+
name: run tests and linters
6+
uses: kubewarden/github-actions/.github/workflows/[email protected]

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "env-variable-secrets-scanner-policy"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
authors = ["raulcabello <[email protected]>"]
55
edition = "2018"
66

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
SOURCE_FILES := $(shell test -e src/ && find src -type f)
2+
VERSION := $(shell sed --posix -n 's,^version = \"\(.*\)\",\1,p' Cargo.toml)
23

34
policy.wasm: $(SOURCE_FILES) Cargo.*
45
cargo build --target=wasm32-wasi --release
56
cp target/wasm32-wasi/release/*.wasm policy.wasm
67

7-
annotated-policy.wasm: policy.wasm metadata.yml
8-
kwctl annotate -m metadata.yml -o annotated-policy.wasm policy.wasm
8+
artifacthub-pkg.yml: metadata.yml Cargo.toml
9+
kwctl scaffold artifacthub --metadata-path metadata.yml --version $(VERSION) \
10+
--output artifacthub-pkg.yml
11+
12+
annotated-policy.wasm: policy.wasm metadata.yml artifacthub-pkg.yml
13+
kwctl annotate -m metadata.yml -u README.md -o annotated-policy.wasm policy.wasm
914

1015
.PHONY: fmt
1116
fmt:
@@ -26,4 +31,4 @@ test: fmt lint
2631
.PHONY: clean
2732
clean:
2833
cargo clean
29-
rm -f policy.wasm annotated-policy.wasm
34+
rm -f policy.wasm annotated-policy.wasm artifacthub-pkg.yml

artifacthub-pkg.yml

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
---
2-
version: 0.1.5
1+
# Kubewarden Artifacthub Package config
2+
#
3+
# Use this config to submit the policy to https://artifacthub.io.
4+
#
5+
# This config can be saved to its default location with:
6+
# kwctl scaffold artifacthub > artifacthub-pkg.yml
7+
version: 0.1.6
38
name: env-variable-secrets-scanner
49
displayName: Environment Variable Secrets Scanner
5-
createdAt: '2023-02-06T16:46:21+02:00'
6-
description: Reject Pods that contain secrets in an environment variable
10+
createdAt: 2023-03-21T12:09:38.582789264Z
11+
description: Policy that inspects env vars and rejects a request if a secret was found
712
license: Apache-2.0
813
homeURL: https://github.com/kubewarden/env-variable-secrets-scanner-policy
914
containersImages:
1015
- name: policy
11-
image: "ghcr.io/kubewarden/policies/env-variable-secrets-scanner:v0.1.5"
16+
image: ghcr.io/kubewarden/policies/env-variable-secrets-scanner:v0.1.6
1217
keywords:
1318
- secrets
1419
- api keys
@@ -18,32 +23,61 @@ keywords:
1823
- confidential data leak
1924
links:
2025
- name: policy
21-
url: https://github.com/kubewarden/env-variable-secrets-scanner-policy/releases/download/v0.1.5/policy.wasm
26+
url: https://github.com/kubewarden/env-variable-secrets-scanner-policy/releases/download/v0.1.6/policy.wasm
2227
- name: source
2328
url: https://github.com/kubewarden/env-variable-secrets-scanner-policy
29+
install: |
30+
The policy can be obtained using [`kwctl`](https://github.com/kubewarden/kwctl):
31+
```console
32+
kwctl pull ghcr.io/kubewarden/policies/env-variable-secrets-scanner:v0.1.6
33+
```
34+
maintainers:
35+
- name: Kubewarden developers
36+
2437
provider:
2538
name: kubewarden
2639
recommendations:
2740
- url: https://artifacthub.io/packages/helm/kubewarden/kubewarden-controller
2841
annotations:
42+
kubewarden/mutation: 'false'
2943
kubewarden/resources: Pod,Deployment,Replicaset,Statefulset,Daemonset,Replicationcontroller,Job,Cronjob
30-
kubewarden/mutation: false
31-
kubewarden/contextAware: false
3244
kubewarden/rules: |
33-
rules:
34-
- apiGroups: [""]
35-
apiVersions: ["v1"]
36-
resources: ["pods"]
37-
operations: ["CREATE"] # kubernetes doesn't allow to add/remove privileged containers to an already running pod
38-
- apiGroups: [""]
39-
apiVersions: ["v1"]
40-
resources: ["replicationcontrollers"]
41-
operations: ["CREATE", "UPDATE"]
42-
- apiGroups: ["apps"]
43-
apiVersions: ["v1"]
44-
resources: ["deployments","replicasets","statefulsets","daemonsets"]
45-
operations: ["CREATE", "UPDATE"]
46-
- apiGroups: ["batch"]
47-
apiVersions: ["v1"]
48-
resources: ["jobs","cronjobs"]
49-
operations: ["CREATE", "UPDATE"]
45+
- apiGroups:
46+
- ''
47+
apiVersions:
48+
- v1
49+
resources:
50+
- pods
51+
operations:
52+
- CREATE
53+
- apiGroups:
54+
- ''
55+
apiVersions:
56+
- v1
57+
resources:
58+
- replicationcontrollers
59+
operations:
60+
- CREATE
61+
- UPDATE
62+
- apiGroups:
63+
- apps
64+
apiVersions:
65+
- v1
66+
resources:
67+
- deployments
68+
- replicasets
69+
- statefulsets
70+
- daemonsets
71+
operations:
72+
- CREATE
73+
- UPDATE
74+
- apiGroups:
75+
- batch
76+
apiVersions:
77+
- v1
78+
resources:
79+
- jobs
80+
- cronjobs
81+
operations:
82+
- CREATE
83+
- UPDATE

metadata.yml

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,15 @@ mutating: false
1919
contextAware: false
2020
executionMode: kubewarden-wapc
2121
annotations:
22+
# artifacthub specific
23+
io.artifacthub.displayName: Environment Variable Secrets Scanner
24+
io.artifacthub.resources: Pod,Deployment,Replicaset,Statefulset,Daemonset,Replicationcontroller,Job,Cronjob
25+
io.artifacthub.keywords: secrets, api keys, tokens, secret leak, confidential data, confidential data leak
26+
io.kubewarden.policy.ociUrl: ghcr.io/kubewarden/policies/env-variable-secrets-scanner
27+
# rest
2228
io.kubewarden.policy.title: env-variable-secrets-scanner
2329
io.kubewarden.policy.description: Policy that inspects env vars and rejects a request if a secret was found
24-
io.kubewarden.policy.author: raulcabello <[email protected]>
30+
io.kubewarden.policy.author: "Kubewarden developers <[email protected]>"
2531
io.kubewarden.policy.url: https://github.com/kubewarden/env-variable-secrets-scanner-policy
2632
io.kubewarden.policy.source: https://github.com/kubewarden/env-variable-secrets-scanner-policy
2733
io.kubewarden.policy.license: Apache-2.0
28-
io.kubewarden.policy.usage: |
29-
This policy will reject pods that contain a secret in an environment variable in any container. It scans environment
30-
variables in all containers, init containers and ephemeral containers. The policy can detect secrets that are leaked via base64 encoded variables.
31-
The policy looks for the following secrets being leaked: RSA private keys, SSH private keys and API tokens for different services like Slack, Facebook tokens, AWS, Google, New Relic Keys, etc.
32-
33-
This policy is powered by the same rule engine used by [rusty hog](https://github.com/newrelic/rusty-hog), an open source secret scanner from New Relic.
34-
35-
The policy can either target `Pods`, or [workload
36-
resources](https://kubernetes.io/docs/concepts/workloads/) (`Deployments`,
37-
`ReplicaSets`, `DaemonSets`, `ReplicationControllers`, `Jobs`, `CronJobs`) by
38-
setting the policy's `spec.rules` accordingly.
39-
40-
Both have trade-offs:
41-
* Policy targets Pods: Different kind of resources (be them native or CRDs) can
42-
create Pods. By having the policy target Pods, we guarantee that all the Pods
43-
are going to be compliant, even those created from CRDs.
44-
However, this could lead to confusion among users, as high level Kubernetes
45-
resources would be successfully created, but they would stay in a non
46-
reconciled state. Example: a Deployment creating a non-compliant Pod would be
47-
created, but it would never have all its replicas running.
48-
* Policy targets workload resources (e.g: Deployment): the policy inspect higher
49-
order resource (e.g. Deployment): users will get immediate feedback about
50-
rejections.
51-
However, non compliant pods created by another high level resource (be it
52-
native to Kubernetes, or a CRD), may not get rejected.
53-

0 commit comments

Comments
 (0)