1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #20106 from jfrazelle/go-generate-json-default-profile

add default seccomp profile as json
This commit is contained in:
David Calavera 2016-02-08 14:48:34 -08:00
commit 3846951fce
8 changed files with 1638 additions and 4 deletions

View file

@ -116,4 +116,4 @@ test-unit: build
$(DOCKER_RUN_DOCKER) hack/make.sh test-unit
validate: build
$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor
$(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

View file

@ -56,6 +56,7 @@ echo
# List of bundles to create when no argument is passed
DEFAULT_BUNDLES=(
validate-dco
validate-default-seccomp
validate-gofmt
validate-lint
validate-pkg

View file

@ -0,0 +1,27 @@
#!/bin/bash
source "${MAKEDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) )
unset IFS
if [ ${#files[@]} -gt 0 ]; then
# We run vendor.sh to and see if we have a diff afterwards
go generate ./profiles/seccomp/ >/dev/null
# Let see if the working directory is clean
diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)"
if [ "$diffs" ]; then
{
echo 'The result of go generate ./profiles/seccomp/ differs'
echo
echo "$diffs"
echo
echo 'Please re-run go generate ./profiles/seccomp/'
echo
} >&2
false
else
echo 'Congratulations! Seccomp profile generation is done correctly.'
fi
fi

1567
profiles/seccomp/default.json Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
// +build ignore
package main
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"github.com/docker/docker/profiles/seccomp"
)
// saves the default seccomp profile as a json file so people can use it as a
// base for their own custom profiles
func main() {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
f := filepath.Join(wd, "default.json")
// get the default profile
p := seccomp.GetDefaultProfile()
// write the default profile to the file
b, err := json.MarshalIndent(p, "", "\t")
if err != nil {
panic(err)
}
if err := ioutil.WriteFile(f, b, 0644); err != nil {
panic(err)
}
}

View file

@ -11,9 +11,11 @@ import (
"github.com/opencontainers/runc/libcontainer/seccomp"
)
//go:generate go run -tags 'seccomp' generate.go
// GetDefaultProfile returns the default seccomp profile.
func GetDefaultProfile() *configs.Seccomp {
return defaultSeccompProfile
return defaultProfile
}
// LoadProfile takes a file path a decodes the seccomp profile.

View file

@ -33,7 +33,8 @@ func arches() []string {
}
}
var defaultSeccompProfile = &configs.Seccomp{
// defaultProfile defines the whitelist for the default seccomp profile.
var defaultProfile = &configs.Seccomp{
DefaultAction: configs.Errno,
Architectures: arches(),
Syscalls: []*configs.Syscall{

View file

@ -5,5 +5,6 @@ package seccomp
import "github.com/opencontainers/runc/libcontainer/configs"
var (
defaultSeccompProfile *configs.Seccomp
// defaultProfile is a nil pointer on unsupported systems.
defaultProfile *configs.Seccomp
)