Skip to content

Commit

Permalink
handle file not found error correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Jan 25, 2025
1 parent a9befac commit a5736b0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions omnibus/python-scripts/security-agent-shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ def is_compliance_config_enabled(core_config: str):

args = parser.parse_args()

with open(args.cfgpath) as f:
core_config = f.read()
with open(args.sysprobe_config) as f:
sysprobe_config = f.read()
core_config = ""
sysprobe_config = ""

try:
with open(args.cfgpath) as f:
core_config = f.read()
except FileNotFoundError:
print(f"Could not find agent config at {args.cfgpath}")

try:
with open(args.sysprobe_config) as f:
sysprobe_config = f.read()
except FileNotFoundError:
print(f"Could not find system-probe config at {args.sysprobe_config}")

if is_runtime_security_config_enabled(core_config, sysprobe_config) or is_compliance_config_enabled(core_config):
os.execlp("security-agent", "security-agent", "-c", args.cfgpath, "--sysprobe-config", args.sysprobe_config)
Expand Down

0 comments on commit a5736b0

Please sign in to comment.