Skip to content

Commit

Permalink
Add error handling for badly formatted env vars
Browse files Browse the repository at this point in the history
When no `=` is present in a line (including blank lines, which shouldn't
cause issues), the parser fails to split on `=` and throws an error.
This simply adds a try-catch around that to ignore values that would
fail.

This is a stopgap fix for #99.
  • Loading branch information
ChandlerSwift committed Jun 21, 2020
1 parent 2807d8b commit 324691a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/web/models/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def envs(self) -> str:
with open(f'/cctf/attacks/{self.id}/env') as f:
envs = {}
for line in f.readlines():
name, value = line.split('=', 1)
envs[name] = value
try:
name, value = line.split('=', 1)
envs[name] = value
except:
pass
return envs

@property
Expand Down

0 comments on commit 324691a

Please sign in to comment.