File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 55import yaml
66
77from .config import generate_session
8+ from .tools import strings
89
910
1011class Yaml (dict ):
@@ -387,4 +388,19 @@ def lint_challenge(path):
387388 if errored :
388389 exit (1 )
389390
391+ # Check that files don't have a flag in them
392+ files = challenge .get ("files" , [])
393+ errored = False
394+ for f in files :
395+ fpath = Path (path ).parent / f
396+ for s in strings (fpath ):
397+ # TODO make flag format customizable
398+ if "flag" in s :
399+ print (
400+ f"Potential flag { s } found in distributed file { fpath .absolute ()} "
401+ )
402+ errored = True
403+ if errored :
404+ exit (1 )
405+
390406 exit (0 )
Original file line number Diff line number Diff line change 1+ import string
2+
3+
4+ def strings (filename , min = 4 ):
5+ """
6+ Python implementation of strings
7+ https://stackoverflow.com/a/17197027
8+ """
9+ with open (filename , errors = "ignore" ) as f :
10+ result = ""
11+ for c in f .read ():
12+ if c in string .printable :
13+ result += c
14+ continue
15+ if len (result ) >= min :
16+ yield result
17+ result = ""
18+ if len (result ) >= min : # catch result at EOF
19+ yield result
You can’t perform that action at this time.
0 commit comments