diff --git a/avd_docs/dockerfile/general/AVD-DS-0017/docs.md b/avd_docs/dockerfile/general/AVD-DS-0017/docs.md index 383a854b..0f12f6db 100644 --- a/avd_docs/dockerfile/general/AVD-DS-0017/docs.md +++ b/avd_docs/dockerfile/general/AVD-DS-0017/docs.md @@ -8,6 +8,6 @@ The instruction 'RUN update' should always be followed by ' update' should always be followed by ' install' in the same RUN statement." } @@ -57,7 +56,7 @@ test_chained_denied { }, { "Cmd": "run", - "Value": ["apt-get install -y --no-install-recommends mysql-client && rm -rf /var/lib/apt/lists/*"], + "Value": ["apt-get install -y --no-install-recommends mysql-client && rm -rf /var/lib/apt/lists/*"], }, { "Cmd": "entrypoint", @@ -77,16 +76,24 @@ test_allowed { }, { "Cmd": "run", - "Value": ["apt-get update && apt-get install -y --no-install-recommends mysql-client && rm -rf /var/lib/apt/lists/*"], + "Value": ["apt-get update && apt-get install -y --no-install-recommends mysql-client && rm -rf /var/lib/apt/lists/*"], }, { "Cmd": "run", - "Value": ["apk update && apk add --no-cache git ca-certificates"], + "Value": ["apk update && apk add --no-cache git ca-certificates"], }, { "Cmd": "run", "Value": ["apk --update add easy-rsa"], }, + { + "Cmd": "run", + "Value": ["/bin/sh /scripts/someScript.sh update"], + }, + { + "Cmd": "run", + "Value": ["apt-get install -y nginx"], + }, { "Cmd": "entrypoint", "Value": ["mysql"], @@ -104,9 +111,151 @@ test_allow_upgrade { }, { "Cmd": "run", - "Value": ["apt-get update && apt upgrade --yes"], + "Value": ["test && apt-get update && apt upgrade --yes"], + }, + ]}]} + + count(r) == 0 +} + +test_without_install_cmd_allowed { + r := deny with input as {"Stages": [{"Name": "alpine:latest", "Commands": [ + { + "Cmd": "from", + "Value": ["alpine:latest"], + }, + { + "Cmd": "run", + "Value": ["echo \"Test\""], + }, + ]}]} + + count(r) == 0 +} + +test_non_package_manager_update_allowed { + r := deny with input as {"Stages": [{"Name": "maven:alpine", "Commands": [ + { + "Cmd": "from", + "Value": ["FROM maven:alpine"], + }, + { + "Cmd": "copy", + "Value": ["build.sbt version.sbt ./"], + }, + { + "Cmd": "run", + "Value": ["sbt update "], }, ]}]} count(r) == 0 } + +test_dnf_update_denied { + r := deny with input as {"Stages": [{ + "Name": "centos:8", + "Commands": [ + { + "Cmd": "from", + "Value": ["centos:8"], + }, + { + "Cmd": "run", + "Value": ["dnf update -y"], + }, + ], + }]} + + count(r) == 1 +} + +test_dnf_update_allowed { + r := deny with input as {"Stages": [{ + "Name": "centos:8", + "Commands": [ + { + "Cmd": "from", + "Value": ["centos:8"], + }, + { + "Cmd": "run", + "Value": ["dnf update && dnf install -y dnf-plugins-core"], + }, + ], + }]} + + count(r) == 0 +} + +test_zypper_update_denied { + r := deny with input as {"Stages": [{ + "Name": "opensuse/tumbleweed", + "Commands": [ + { + "Cmd": "from", + "Value": ["opensuse/tumbleweed"], + }, + { + "Cmd": "run", + "Value": ["zypper up -y"], + }, + ], + }]} + + count(r) == 1 +} + +test_zypper_update_allowed { + r := deny with input as {"Stages": [{ + "Name": "opensuse/tumbleweed", + "Commands": [ + { + "Cmd": "from", + "Value": ["opensuse/tumbleweed"], + }, + { + "Cmd": "run", + "Value": ["zypper up -y && zypper install -y curl wget zip unzip tar git"], + }, + ], + }]} + + count(r) == 0 +} + +test_yum_update_denied { + r := deny with input as {"Stages": [{ + "Name": "centos:latest", + "Commands": [ + { + "Cmd": "from", + "Value": ["centos:latest"], + }, + { + "Cmd": "run", + "Value": ["yum update -y"], + }, + ], + }]} + + count(r) == 1 +} + +test_yum_update_allowed { + r := deny with input as {"Stages": [{ + "Name": "centos:latest", + "Commands": [ + { + "Cmd": "from", + "Value": ["centos:latest"], + }, + { + "Cmd": "run", + "Value": ["yum update -y && yum -y install java-11-openjdk"], + }, + ], + }]} + + count(r) == 0 +}