Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 32b6092

Browse files
committed
Merge pull request #3 from deep-security/new-cli
Completely new CLI
2 parents ce00697 + f90aa4e commit 32b6092

File tree

161 files changed

+1773
-471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1773
-471
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ dist/
1414
downloads/
1515
eggs/
1616
.eggs/
17-
lib/
1817
lib64/
1918
parts/
2019
sdist/

ISSUE_TEMPLATE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Thanks for taking the time to submit an issue. There's a couple of things that will make this easier for everyone involve. If you could please take the time to complete the list below, it's much appreciated.
2+
3+
- [ ] I'm using Deep Security version ____
4+
5+
- [ ] I'm using the latest version of this repo
6+
7+
- [ ] My Deep Security Manager has a self-signed or non-validating SSL certificate
8+
9+
## Current Output
10+
11+
Please re-run the command using ```--verbose``` and provide the complete output below.
12+
13+
## Addition Details
14+
15+
Can you also please fill in each of the remaining sections.
16+
17+
### Expected behaviour
18+
19+
### Actual behaviour
20+
21+
### Steps to reproduce the behaviour

README.md

+240-53
Large diffs are not rendered by default.

ds-to-aws-waf.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#! /usr/bin/env python
2+
3+
# Standard libraries
4+
import argparse
5+
import os
6+
import urllib2
7+
import sys
8+
9+
# 3rd party libraries
10+
import boto3
11+
import boto3.session
12+
import netaddr
13+
14+
# project libraries
15+
import lib.core
16+
import lib.iplists
17+
import lib.sqli
18+
19+
def parse_args(str_to_parse=None):
20+
"""
21+
Parse the command line args
22+
"""
23+
cmd = ""
24+
if len(sys.argv) > 1:
25+
cmd = sys.argv[1]
26+
27+
return cmd
28+
29+
class Script(lib.core.ScriptContext):
30+
def __init__(self, command_to_run):
31+
self.command_to_run = command_to_run
32+
self.available_commands = {
33+
'iplist':
34+
{
35+
'help': 'Push a Deep Security IP list to an AWS WAF IP Set',
36+
'cmd': lib.iplists.run_script,
37+
},
38+
'sqli':
39+
{
40+
'help': 'Determine which instances protected by Deep Security should also be protected by AWS WAF SQLi rules',
41+
'cmd': lib.sqli.run_script,
42+
},
43+
}
44+
45+
if not self.command_to_run in self.available_commands.keys():
46+
self.print_help()
47+
else:
48+
# run a specific command
49+
self.available_commands[self.command_to_run]['cmd'](sys.argv[1:])
50+
51+
def print_help(self):
52+
"""
53+
Print the command line syntax available to the user
54+
"""
55+
self.update_user("usage: ds-to-aws-waf [COMMAND]\n For more help on a specific command, type ds-to-aws-waf [COMMAND] --help\n\n Available commands:\n")
56+
for cmd, data in self.available_commands.items():
57+
self.update_user(" {}\n > {}".format(cmd, data['help']))
58+
self.update_user("")
59+
60+
def main():
61+
"""
62+
Run the script from the command line
63+
"""
64+
context = Script(parse_args())
65+
66+
if __name__ == '__main__': main()

0 commit comments

Comments
 (0)