Skip to content

Commit b013be6

Browse files
Merge pull request #25 from intelops/test/scsctl_cicd_integration
Test/scsctl cicd integration
2 parents 94e4517 + aaa9981 commit b013be6

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

.github/workflows/scsctl_test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: scsctl_test
2+
on:
3+
push:
4+
branches: [ main ]
5+
workflow_dispatch:
6+
7+
jobs:
8+
container-test-job:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Pull pyroscope/pyroscope:latest image
15+
run: docker pull pyroscope/pyroscope:latest
16+
17+
- name: Run pyroscope
18+
run: docker run -d -it -p 4040:4040 pyroscope/pyroscope:latest server
19+
20+
- name: Start a local k8s cluster
21+
uses: jupyterhub/action-k3s-helm@v3
22+
with:
23+
k3s-channel: latest
24+
25+
- name: Verify function of k8s, kubectl, and helm
26+
run: |
27+
echo "kubeconfig: $KUBECONFIG"
28+
kubectl version
29+
kubectl get pods --all-namespaces
30+
31+
helm version
32+
33+
# helm install falco -f custom-rules.yaml --set "falco.rules_file={/etc/falco/falco_rules.local.yaml,/etc/falco/rules.d}" --set falcoctl.artifact.install.enabled=false --set falcoctl.artifact.follow.enabled=false --set falco.json_output=true --set falco.file_output.enabled=true falcosecurity/falco
34+
- name: Run falco in k3s
35+
run: |
36+
helm repo add falcosecurity https://falcosecurity.github.io/charts
37+
helm install falco -f custom-rules.yaml --set "falco.rules_file={/etc/falco/falco_rules.local.yaml,/etc/falco/rules.d}" --set falcoctl.artifact.install.enabled=false --set falcoctl.artifact.follow.enabled=false --set falco.json_output=true --set falco.file_output.enabled=true falcosecurity/falco
38+
sleep 30
39+
- name: Run pyroscope in k3s
40+
run: |
41+
helm repo add pyroscope-io https://pyroscope-io.github.io/helm-chart
42+
helm install pyroscope pyroscope-io/pyroscope
43+
sleep 30
44+
- name: List pods
45+
run: |
46+
kubectl get pods
47+
- name: Install a python cli tool from test pypi and run it
48+
run: |
49+
python -m pip install --upgrade pip
50+
python -m pip install --upgrade build
51+
python -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple scsctl
52+
- name: Run clickhouse
53+
run: |
54+
docker run -d --network host --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
55+
sleep 5
56+
- name: run scsctl
57+
run: |
58+
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=pyroscope,app.kubernetes.io/instance=pyroscope" -o jsonpath="{.items[0].metadata.name}")
59+
scsctl scan --pyroscope_app_name pyroscope.server --docker_image_name pyroscope/pyroscope:latest --pyroscope_url http://localhost:4040 --falco_pod_name $POD_NAME --falco_target_deployment_name pyroscope --db_enabled --falco_enabled --non_interactive

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,38 @@ db_enabled: true
149149
falco_enabled: true
150150
docker_file_folder_path: /home/jegath/Documents/intelops/sps/dagflow/app/
151151
```
152+
153+
### Running the tool in ci/cd environment
154+
155+
To run scsctl in ci/cd environment,
156+
1. Install scsctl from pypi
157+
2. Run the tool
158+
159+
Example
160+
161+
162+
```yaml
163+
name: scsctl_test
164+
on:
165+
push:
166+
branches: [ main ]
167+
jobs:
168+
container-test-job:
169+
runs-on: ubuntu-latest
170+
171+
steps:
172+
- uses: actions/checkout@v3
173+
174+
- name: Pull pyroscope/pyroscope:latest image
175+
run: docker pull pyroscope/pyroscope:latest
176+
177+
- name: Install a python cli tool from test pypi and run it
178+
run: |
179+
python -m pip install --upgrade pip
180+
python -m pip install --upgrade build
181+
python -m pip install scsctl
182+
183+
- name: run scsctl tool
184+
run: |
185+
scsctl scan --pyroscope_app_name pyroscope.server --docker_image_name pyroscope/pyroscope:latest --pyroscope_url https://369d-111-92-44-131.ngrok-free.app --non_interactive
186+
```

custom-rules.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
customRules:
2+
falco_rules.yaml: |-
3+
- rule: File Opened in Container
4+
desc: Detect any file opened in container
5+
condition: open_file_in_container
6+
output: file - %fd.name type - %evt.type Deplyment name - %k8s.deployment.name time - %evt.time.iso8601
7+
priority: INFO
8+
tags:
9+
- scsctl
10+
- macro: open_file_in_container
11+
condition: >
12+
k8s.deployment.name startswith "pyroscope" and
13+
evt.type = "openat"

0 commit comments

Comments
 (0)