Skip to content

Commit 662ad51

Browse files
authored
Add hadolint to the lint steps (#58)
* Lint Dockerfiles with hadolint
1 parent 3464a19 commit 662ad51

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ctfcli/utils/challenge.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
import subprocess
23

34
import click
45
import yaml
@@ -314,8 +315,17 @@ def lint_challenge(path):
314315
print("Dockerfile missing EXPOSE")
315316
exit(1)
316317

318+
# Check Dockerfile with hadolint
319+
proc = subprocess.run(
320+
["docker", "run", "--rm", "-i", "hadolint/hadolint"],
321+
input=dockerfile.encode(),
322+
)
323+
if proc.returncode != 0:
324+
print("Hadolint found Dockerfile lint issues, please resolve")
325+
exit(1)
326+
317327
# Check that all files exists
318-
files = challenge.get("files")
328+
files = challenge.get("files", [])
319329
errored = False
320330
for f in files:
321331
fpath = Path(path).parent / f

0 commit comments

Comments
 (0)