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

Commit

Permalink
Merge pull request #3 from deep-security/new-cli
Browse files Browse the repository at this point in the history
Completely new CLI
  • Loading branch information
marknca committed Mar 8, 2016
2 parents ce00697 + f90aa4e commit 32b6092
Show file tree
Hide file tree
Showing 161 changed files with 1,773 additions and 471 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
21 changes: 21 additions & 0 deletions ISSUE_TEMPLATE
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
293 changes: 240 additions & 53 deletions README.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions ds-to-aws-waf.py
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()
Loading

0 comments on commit 32b6092

Please sign in to comment.