forked from sysdiglabs/sysdig-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_secure_system_falco_rules.py
More file actions
executable file
·46 lines (37 loc) · 983 Bytes
/
set_secure_system_falco_rules.py
File metadata and controls
executable file
·46 lines (37 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
#
# Set the sysdig secure system rules file.
# This script takes a user token and a falco rules file (yaml) as input, and sets the
# system falco rules file for this customer to that file.
#
import sys
import yaml
from sdcclient import SdSecureClient
#
# Parse arguments
#
if len(sys.argv) != 3:
print(('usage: %s <sysdig-token> <falco-rules-file>' % sys.argv[0]))
print('You can find your token at https://app.sysdigcloud.com/#/settings/user')
sys.exit(1)
sdc_token = sys.argv[1]
#
# Load the config file
#
with open(sys.argv[2]) as cfile:
yaml_conf = cfile.read()
# Verify that the content is valid yaml
parsed_yaml_conf = yaml.safe_load(yaml_conf)
sdclient = SdSecureClient(sdc_token, 'https://secure.sysdig.com')
#
# Push the configuration
#
ok, res = sdclient.set_system_falco_rules(yaml_conf)
#
# Check if everything went well
#
if ok:
print('system falco rules set successfully')
else:
print(res)
sys.exit(1)