File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ from cbapi .response .models import SensorGroup
5
+ from cbapi .example_helpers import build_cli_parser , get_cb_response_object
6
+
7
+
8
+ def main ():
9
+ parser = build_cli_parser ("Check datasharing settings on server" )
10
+
11
+ args = parser .parse_args ()
12
+ cb = get_cb_response_object (args )
13
+
14
+ virustotal_groups = []
15
+ for sg in cb .select (SensorGroup ):
16
+ settings = cb .get_object ("/api/v1/group/{0}/datasharing" .format (sg .id )) or []
17
+ for setting in settings :
18
+ if setting .get ("what" ) == "BIN" and setting .get ("who" ) == "VIRUSTOTAL" :
19
+ virustotal_groups .append (sg )
20
+
21
+ if len (virustotal_groups ) == 0 :
22
+ print ("No sensor groups are configured to send unknown binaries to VirusTotal" )
23
+ return 0
24
+ elif len (virustotal_groups ) == len (cb .select (SensorGroup )):
25
+ print ("**ALL** sensor groups are configured to send unknown binaries to VirusTotal" )
26
+ return 1
27
+ else :
28
+ print ("The following sensor groups are configured to send unknown binaries to VirusTotal:" )
29
+ for sg in virustotal_groups :
30
+ print (" id {0}: {1}" .format (sg .id , sg .name ))
31
+ return 1
32
+
33
+
34
+ if __name__ == "__main__" :
35
+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments