This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from deep-security/new-cli
Completely new CLI
- Loading branch information
Showing
161 changed files
with
1,773 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ dist/ | |
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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. | ||
|
||
- [ ] I'm using Deep Security version ____ | ||
|
||
- [ ] I'm using the latest version of this repo | ||
|
||
- [ ] My Deep Security Manager has a self-signed or non-validating SSL certificate | ||
|
||
## Current Output | ||
|
||
Please re-run the command using ```--verbose``` and provide the complete output below. | ||
|
||
## Addition Details | ||
|
||
Can you also please fill in each of the remaining sections. | ||
|
||
### Expected behaviour | ||
|
||
### Actual behaviour | ||
|
||
### Steps to reproduce the behaviour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#! /usr/bin/env python | ||
|
||
# Standard libraries | ||
import argparse | ||
import os | ||
import urllib2 | ||
import sys | ||
|
||
# 3rd party libraries | ||
import boto3 | ||
import boto3.session | ||
import netaddr | ||
|
||
# project libraries | ||
import lib.core | ||
import lib.iplists | ||
import lib.sqli | ||
|
||
def parse_args(str_to_parse=None): | ||
""" | ||
Parse the command line args | ||
""" | ||
cmd = "" | ||
if len(sys.argv) > 1: | ||
cmd = sys.argv[1] | ||
|
||
return cmd | ||
|
||
class Script(lib.core.ScriptContext): | ||
def __init__(self, command_to_run): | ||
self.command_to_run = command_to_run | ||
self.available_commands = { | ||
'iplist': | ||
{ | ||
'help': 'Push a Deep Security IP list to an AWS WAF IP Set', | ||
'cmd': lib.iplists.run_script, | ||
}, | ||
'sqli': | ||
{ | ||
'help': 'Determine which instances protected by Deep Security should also be protected by AWS WAF SQLi rules', | ||
'cmd': lib.sqli.run_script, | ||
}, | ||
} | ||
|
||
if not self.command_to_run in self.available_commands.keys(): | ||
self.print_help() | ||
else: | ||
# run a specific command | ||
self.available_commands[self.command_to_run]['cmd'](sys.argv[1:]) | ||
|
||
def print_help(self): | ||
""" | ||
Print the command line syntax available to the user | ||
""" | ||
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") | ||
for cmd, data in self.available_commands.items(): | ||
self.update_user(" {}\n > {}".format(cmd, data['help'])) | ||
self.update_user("") | ||
|
||
def main(): | ||
""" | ||
Run the script from the command line | ||
""" | ||
context = Script(parse_args()) | ||
|
||
if __name__ == '__main__': main() |
Oops, something went wrong.