Browse code

add validation for generating default secccomp profile

Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2016/02/09 03:52:53
Showing 4 changed files
... ...
@@ -116,4 +116,4 @@ test-unit: build
116 116
 	$(DOCKER_RUN_DOCKER) hack/make.sh test-unit
117 117
 
118 118
 validate: build
119
-	$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor
119
+	$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-default-seccomp validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor
... ...
@@ -56,6 +56,7 @@ echo
56 56
 # List of bundles to create when no argument is passed
57 57
 DEFAULT_BUNDLES=(
58 58
 	validate-dco
59
+	validate-default-seccomp
59 60
 	validate-gofmt
60 61
 	validate-lint
61 62
 	validate-pkg
62 63
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+#!/bin/bash
1
+
2
+source "${MAKEDIR}/.validate"
3
+
4
+IFS=$'\n'
5
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) )
6
+unset IFS
7
+
8
+if [ ${#files[@]} -gt 0 ]; then
9
+	# We run vendor.sh to and see if we have a diff afterwards
10
+	go generate ./profiles/seccomp/ >/dev/null
11
+	# Let see if the working directory is clean
12
+	diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)"
13
+	if [ "$diffs" ]; then
14
+		{
15
+			echo 'The result of go generate ./profiles/seccomp/ differs'
16
+			echo
17
+			echo "$diffs"
18
+			echo
19
+			echo 'Please re-run go generate ./profiles/seccomp/'
20
+			echo
21
+		} >&2
22
+		false
23
+	else
24
+		echo 'Congratulations! Seccomp profile generation is done correctly.'
25
+	fi
26
+fi
... ...
@@ -29,7 +29,7 @@ func main() {
29 29
 		panic(err)
30 30
 	}
31 31
 
32
-	if err := ioutil.WriteFile(f, b, 0755); err != nil {
32
+	if err := ioutil.WriteFile(f, b, 0644); err != nil {
33 33
 		panic(err)
34 34
 	}
35 35
 }