Skip to content

Commit 28007d9

Browse files
authored
Merge pull request #96 from fawdyinc/feat/allow-nproc-docker-stats
Allow nproc and docker stats
2 parents 5b09938 + 516106c commit 28007d9

6 files changed

Lines changed: 30 additions & 1 deletion

File tree

manifest/manifest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func mustLoadEmbedded(t *testing.T) map[string]*Manifest {
2020
func TestLoadEmbeddedCountAndNameMatch(t *testing.T) {
2121
registry := mustLoadEmbedded(t)
2222

23-
if got, want := len(registry), 178; got != want {
23+
if got, want := len(registry), 180; got != want {
2424
t.Fatalf("len(registry) = %d, want %d", got, want)
2525
}
2626

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: docker_stats
2+
description: Display a live stream of container resource usage statistics
3+
category: containers
4+
flags:
5+
- flag: "--no-stream"
6+
- flag: "--all"
7+
- flag: "--format"
8+
takes_value: true
9+
stdin: false
10+
stdout: true

manifest/manifests/nproc.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: nproc
2+
description: Print the number of processing units available
3+
category: system
4+
flags:
5+
- flag: "--all"
6+
- flag: "--ignore"
7+
takes_value: true
8+
stdin: false
9+
stdout: true

security_pipeline_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ func TestSubcommandBypass_DockerDangerous(t *testing.T) {
794794
mustAccept(t, registry, "docker ps -a")
795795
mustAccept(t, registry, "docker logs container_id")
796796
mustAccept(t, registry, "docker inspect container_id")
797+
mustAccept(t, registry, "docker stats --no-stream container_id")
797798
}
798799

799800
func TestSubcommandBypass_SystemctlDangerous(t *testing.T) {

validator/attack_vectors_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ func TestSubcommandBypass(t *testing.T) {
621621
expectAllow(t, err, "docker inspect is allowed")
622622
})
623623

624+
t.Run("docker_stats_allowed", func(t *testing.T) {
625+
err := validateOne(t, "docker", "stats", "--no-stream", "container")
626+
expectAllow(t, err, "docker stats is allowed")
627+
})
628+
624629
t.Run("kubectl_get_allowed", func(t *testing.T) {
625630
err := validateOne(t, "kubectl", "get", "pods", "-n", "default")
626631
expectAllow(t, err, "kubectl get is allowed")

validator/validator_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func TestValidatesSubcommands(t *testing.T) {
118118
t.Fatalf("validate docker ps --format: %v", err)
119119
}
120120

121+
if err := validateOne(t, "docker", "stats", "--no-stream"); err != nil {
122+
t.Fatalf("validate docker stats --no-stream: %v", err)
123+
}
124+
121125
err := validateOne(t, "docker", "run", "alpine")
122126
if err == nil {
123127
t.Fatal("expected docker run to be rejected")

0 commit comments

Comments
 (0)