Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit 0628fd3

Browse files
committed
feat(polaris_scanner): initial version of polaris scanner app
1 parent 94dabcd commit 0628fd3

File tree

12 files changed

+977
-2
lines changed

12 files changed

+977
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ bld/
4141
# MSTest test Results
4242
[Tt]est[Rr]esult*/
4343
[Bb]uild[Ll]og.*
44+
45+
/src/scanners/polaris/polaris.exe

src/scanners/polaris/TECH_DESIGN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The scanner adjusts to the underlying Polaris app - it's written in golang and a
2323

2424
- Polaris config should be located at path specified in `POLARIS_CONFIG_PATH` environment variable path;
2525
- exact Blob Storage service implementation is constructed based on `BLOB_STORAGE_SERVICE_TYPE` environment variable;
26-
- if is running out of the target cluster, `KUBECONFIG_PATH` environment variable should point to kubeconfig file;
26+
- if is running out of the target cluster, `KUBECONFIG` environment variable should point to kubeconfig file;
2727
- `SCANNER_IDENTIFIER` and `SCANNER_PERIODICITY` is deployment-time scanner identifier and periodicity;
2828
- `LOG_FORMAT` - `plain-text` or `json`.
2929

@@ -70,7 +70,7 @@ After each audit iteration is completed, the scanner should update general metad
7070
{
7171
"scanner-type": "polaris",
7272
"scanner-id": "{UUID}",
73-
"scanner-periodicity": "on-cron-{cron-expression}",
73+
"scanner-periodicity": "{cron-expression}",
7474
"heartbeat-periodicity": "int",
7575
"heartbeat": 1579619671
7676
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
checks:
2+
# resources
3+
cpuRequestsMissing: warning
4+
cpuLimitsMissing: warning
5+
memoryRequestsMissing: warning
6+
memoryLimitsMissing: warning
7+
# images
8+
tagNotSpecified: error
9+
pullPolicyNotAlways: ignore
10+
imageRegistry: warning
11+
# healthChecks
12+
readinessProbeMissing: warning
13+
livenessProbeMissing: warning
14+
# networking
15+
hostNetworkSet: warning
16+
hostPortSet: warning
17+
# security
18+
hostIPCSet: error
19+
hostPIDSet: error
20+
notReadOnlyRootFileSystem: warning
21+
privilegeEscalationAllowed: error
22+
runAsRootAllowed: warning
23+
runAsPrivileged: error
24+
dangerousCapabilities: error
25+
insecureCapabilities: warning
26+
27+
customChecks:
28+
resourceLimits:
29+
containers:
30+
exclude:
31+
- initContainer
32+
successMessage: Resource limits are within the required range
33+
failureMessage: Resource limits should be within the required range
34+
category: Resources
35+
target: Container
36+
schema:
37+
'$schema': http://json-schema.org/draft-07/schema
38+
type: object
39+
required:
40+
- resources
41+
properties:
42+
resources:
43+
type: object
44+
required:
45+
- limits
46+
properties:
47+
limits:
48+
type: object
49+
required:
50+
- memory
51+
- cpu
52+
properties:
53+
memory:
54+
type: string
55+
resourceMinimum: 100M
56+
resourceMaximum: 6G
57+
cpu:
58+
type: string
59+
resourceMinimum: 100m
60+
resourceMaximum: "2"
61+
imageRegistry:
62+
successMessage: Image comes from allowed registries
63+
failureMessage: Image should not be from disallowed registry
64+
category: Images
65+
target: Container
66+
schema:
67+
'$schema': http://json-schema.org/draft-07/schema
68+
type: object
69+
properties:
70+
image:
71+
type: string
72+
not:
73+
pattern: ^quay.io
74+
75+
controllersToScan:
76+
- Deployments
77+
- StatefulSets
78+
- DaemonSets
79+
- CronJobs
80+
- Jobs
81+
- ReplicationControllers
82+
exemptions:
83+
- controllerNames:
84+
- dns-controller
85+
- datadog-datadog
86+
- kube-flannel-ds
87+
- kube2iam
88+
- aws-iam-authenticator
89+
- datadog
90+
- kube2iam
91+
rules:
92+
- hostNetworkSet
93+
- controllerNames:
94+
- aws-iam-authenticator
95+
- aws-cluster-autoscaler
96+
- kube-state-metrics
97+
- dns-controller
98+
- external-dns
99+
- dnsmasq
100+
- autoscaler
101+
- kubernetes-dashboard
102+
- install-cni
103+
- kube2iam
104+
rules:
105+
- readinessProbeMissing
106+
- livenessProbeMissing
107+
- controllerNames:
108+
- aws-iam-authenticator
109+
- nginx-ingress-controller
110+
- nginx-ingress-default-backend
111+
- aws-cluster-autoscaler
112+
- kube-state-metrics
113+
- dns-controller
114+
- external-dns
115+
- kubedns
116+
- dnsmasq
117+
- autoscaler
118+
- tiller
119+
- kube2iam
120+
rules:
121+
- runAsRootAllowed
122+
- controllerNames:
123+
- aws-iam-authenticator
124+
- nginx-ingress-controller
125+
- nginx-ingress-default-backend
126+
- aws-cluster-autoscaler
127+
- kube-state-metrics
128+
- dns-controller
129+
- external-dns
130+
- kubedns
131+
- dnsmasq
132+
- autoscaler
133+
- tiller
134+
- kube2iam
135+
rules:
136+
- notReadOnlyRootFileSystem
137+
- controllerNames:
138+
- cert-manager
139+
- dns-controller
140+
- kubedns
141+
- dnsmasq
142+
- autoscaler
143+
rules:
144+
- cpuRequestsMissing
145+
- cpuLimitsMissing
146+
- memoryRequestsMissing
147+
- memoryLimitsMissing
148+
- controllerNames:
149+
- kube2iam
150+
rules:
151+
- runAsPrivileged
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
scanner:
2+
id: 8fc1b601-d5a2-466d-8236-c747c1dc02a2
3+
periodicity: "0 2 * * *"
4+
heartbeat-periodicity: 7200
5+
version: 0.1.0
6+
polaris:
7+
configPath: ./examples/polaris-config.yaml
8+
version: 0.6.0
9+
blobStorageType: azure-blob-storage
10+
azureBlobConfig:
11+
storageBaseUrl: https://BLOB_NAME.blob.core.windows.net/CONTAINER_NAME
12+
sasToken: insert-sas-token-here
13+
logFormat: plain-text

src/scanners/polaris/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/deepnetworkgmbh/joseki/src/scanners/polaris
2+
3+
go 1.13
4+
5+
require (
6+
github.com/Azure/azure-storage-blob-go v0.8.0
7+
github.com/fairwindsops/polaris v0.0.0-20200129175304-73c492333435
8+
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93
9+
)

0 commit comments

Comments
 (0)