Code Monkey home page Code Monkey logo

sigsci_site_manager's Introduction

Signal Sciences Site Management Tool

Installation

$ pip3 install sigsci_site_manager

Usage

Main Usage

$ sigsci_site_manager --help
usage: sigsci_site_manager [-h] [--corp CORP] [--user [USERNAME]]
                           [--password [PASSWORD] | --token [APITOKEN]]
                           {list,deploy,backup,clone} ...

Signal Sciences site management

optional arguments:
  -h, --help            show this help message and exit
  --corp CORP, -c CORP  Signal Sciences corp name. If omitted will try to use
                        value in $SIGSCI_CORP.
  --user [USERNAME], -u [USERNAME]
                        Signal Sciences username. If omitted will try to use
                        value in $SIGSCI_EMAIL.
  --password [PASSWORD], -p [PASSWORD]
                        Signal Sciences password. If omitted will try to use
                        value in $SIGSCI_PASSWORD
  --token [APITOKEN], -t [APITOKEN]
                        Signal Sciences API token. If omitted will try to use
                        value in $SIGSCI_API_TOKEN

Commands:
  {list,deploy,backup,clone,merge}
    list                List sites
    deploy              Deploy a new site from a file
    backup              Backup a site to a file
    clone               Clone an existing site to a new site
    merge               Merge a site onto another

List Command

$ sigsci_site_manager list --help
usage: sigsci_site_manager list [-h] [--filter PATTERN]

optional arguments:
  -h, --help  show this help message and exit
  --filter PATTERN  Filter site names using a wildcard pattern

Backup Command

$ sigsci_site_manager backup --help
usage: sigsci_site_manager backup [-h] --name NAME --out FILENAME

optional arguments:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  Site name
  --out FILENAME, -o FILENAME
                        File to save backup to

Deploy Command

$ sigsci_site_manager deploy --help
usage: sigsci_site_manager deploy [-h] --name NAME
                                  [--display-name "Display Name"] --file
                                  FILENAME [--dry-run]
                                  [--include CATEGORY_LIST | --exclude CATEGORY_LIST]

optional arguments:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  Identifying name of the site
  --display-name "Display Name", -N "Display Name"
                        Display name of the site
  --file FILENAME, -f FILENAME
                        Name of site file
  --dry-run             Print actions without making any changes
  --include CATEGORY_LIST
                        CSV list of categories to include in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES
  --exclude CATEGORY_LIST
                        CSV list of categories to exclude in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES

Clone Command

$ sigsci_site_manager clone --help
usage: sigsci_site_manager clone [-h] --src SITE --dest SITE
                                 [--display-name "Display Name"] [--dry-run]
                                 [--include CATEGORY_LIST | --exclude CATEGORY_LIST]

optional arguments:
  -h, --help            show this help message and exit
  --src SITE, -s SITE   Site to clone from
  --dest SITE, -d SITE  Site to clone to
  --display-name "Display Name", -N "Display Name"
                        Display name of the new site
  --dry-run             Print actions without making any changes
  --include CATEGORY_LIST
                        CSV list of categories to include in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES
  --exclude CATEGORY_LIST
                        CSV list of categories to exclude in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES

Merge Command

$ sigsci_site_manager merge --help
usage: sigsci_site_manager merge [-h] --dest SITE
                                 [--src SITE | --file FILENAME] [--dry-run]
                                 [--include CATEGORY_LIST | --exclude CATEGORY_LIST]
                                 [--yes]

optional arguments:
  -h, --help            show this help message and exit
  --dest SITE, -d SITE  Site to merge onto (accepts wildcard pattern)
  --src SITE, -s SITE   Site to merge from
  --file FILENAME, -f FILENAME
                        Name of site file to merge from
  --dry-run             Print actions without making any changes
  --include CATEGORY_LIST
                        CSV list of categories to include in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES
  --exclude CATEGORY_LIST
                        CSV list of categories to exclude in the merge.
                        Options: RULE_LISTS, CUSTOM_SIGNALS, REQUEST_RULES,
                        SIGNAL_RULES, TEMPLATED_RULES, CUSTOM_ALERTS,
                        SITE_MEMBERS, INTEGRATIONS, ADVANCED_RULES
  --yes, -y             Automatic yes to prompts

User Command

$ sigsci_site_manager user --help
usage: sigsci_site_manager user [-h] [--site SITE] [--dry-run]
                         {add,list,member,remove} ...

optional arguments:
  -h, --help            show this help message and exit
  --site SITE, -s SITE  Name of site
  --dry-run             Print actions without making any changes

Manage User Command:
  {add,list,member,remove}
    add                 Add user to corp, or to site if site is specified
    list                List users in corp, or in site if site is specified
    member              list user site/role membership
    remove              remove user from corp/site

User add SubCommand

$ sigsci_site_manager user add --help
usage: sigsci_site_manager user add [-h] [--id EMAIL_ID | --file FILENAME]
                             [--role {admin,user,observer,owner}] 
                             [--override]

optional arguments:
  -h, --help            show this help message and exit
  --id EMAIL_ID, -i EMAIL_ID
                        User to add to site
  --file FILENAME, -f FILENAME
                        Path to file containing email_id,role pair one per
                        line. Adds each user to site if site is specified,
                        otherwise adds user from the corp org. Use - to read
                        input from stdin

add user:
  --role {admin,user,observer,owner}, -r {admin,user,observer,owner}
                        Role to assign user in site. Default role is observer
  --api-user, -a        Enable as api user. Enables user for api access

User list Subcommand

$ sigsci_site_manager user list --help
usage: sigsci_site_manager user list [-h]

optional arguments:
  -h, --help  show this help message and exit

User member Subcommand

$ sigsci_site_manager user member --help
usage: sigsci_site_manager user member [-h] --id EMAIL_ID

optional arguments:
  -h, --help            show this help message and exit

list user site/role membership:
  --id EMAIL_ID, -i EMAIL_ID
                        Email id for the user to examine site/corp membership.

User remove Subcommand

$ sigsci_site_manager user remove  --help
usage: sigsci_site_manager user remove [-h] [--id EMAIL_ID | --file FILENAME]

optional arguments:
  -h, --help            show this help message and exit
  --id EMAIL_ID, -i EMAIL_ID
                        Email id for the user to delete. Deletes user from
                        site if site is specified, otherwise deletes user from
                        the system
  --file FILENAME, -f FILENAME
                        Path to file containing, email_id one per line.Deletes
                        user from site if site is specified, otherwise deletes
                        user from the system. Use - to read input from stdin

Validate Command

$ sigsci_site_manager validate --help
usage: sigsci_site_manager validate [-h] --name NAME --target URL [--dry-run]

optional arguments:
  -h, --help            show this help message and exit
  --name NAME, -n NAME  Site name
  --target URL, -d URL  URL to test against
  --dry-run             Print actions without making any changes

Migrate Command

$ sigsci_site_manager migrate --help
usage: sigsci_site_manager migrate [-h] --dest-corp DESTCORP --file FILENAME
                                   [--out OUTPUTFILE] [--strip STRIP]
                                   [--migrate-users]

optional arguments:
  -h, --help            show this help message and exit
  --dest-corp DESTCORP, -d DESTCORP
                        Destination corp to migrate to
  --file FILENAME, -f FILENAME
                        Filename of to migrate
  --out OUTPUTFILE, -o OUTPUTFILE
                        File to save migrated backup to, defaults to
                        "migrated_<backup filename>"
  --strip STRIP, -s STRIP
                        Strip all items with corp dependencies from the
                        migrated backup
  --migrate-users, -u   Preserve users in migrated backup

sigsci_site_manager's People

Contributors

foospidy avatar jdempsey77 avatar joeyleake avatar pizen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sigsci_site_manager's Issues

Adding trailing "/" to target will cause validate to fail

Run validate without a slash

Validating deployment of site 'site'
Running test cases...
 786d4e2a-3df6-418d-8be8-edc8c6b69072: GET /?<script>alert('test');</script>
Waiting for SigSci agent to upload request logs...
Searching request log...
 786d4e2a-3df6-418d-8be8-edc8c6b69072...
 Matched test case 786d4e2a-3df6-418d-8be8-edc8c6b69072 with request 5dc1ef5ff7ad7a002200d225
Success

Now add a slash to the end of the site

Validating deployment of site 'site'
Running test cases...
 953c21b5-d617-48b0-8a96-d4a150287ca2: GET /?<script>alert('test');</script>
Waiting for SigSci agent to upload request logs...
Searching request log...
 953c21b5-d617-48b0-8a96-d4a150287ca2...
 Failed to find test case 953c21b5-d617-48b0-8a96-d4a150287ca2 in request log
Failed```

Ignore expired site rules

Suggestion to ignore any site rules that are expired as importing them into a new site will cause errors.

Error while merging site rules to existing site from configuration backup

Merging site rules...
Traceback (most recent call last):
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python39\Scripts\sigsci_site_manager.exe_main
.py", line 7, in
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\site_manager.py", line 449, in main
args.func(args)
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\site_manager.py", line 105, in do_merge
merge(api, site, args.src_site, args.file_name,
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\merge.py", line 420, in merge
merges(api, dst_site, data, categories)
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\merge.py", line 405, in merges
steps[k]0
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\merge.py", line 159, in merge_site_rules
if equal_rules(rule, item):
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\util.py", line 97, in equal_rules
a = filter_data(in_a, keys)
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\util.py", line 17, in filter_data
ret = {k: data[k] for k in keys}
File "c:\users\xxxxx\appdata\local\programs\python\python39\lib\site-packages\sigsci_site_manager\util.py", line 17, in
ret = {k: data[k] for k in keys}

SigSci API requires site names be lowercase but that is not enforced by input validation, causing confusion.

The SigSci API requires that the site name be all lowercase. For example, attempting to clone a site with --dest Site_Name returns an error that the site already exists. However, what is happening is that the API is returning the error "Invalid resource request", which is being interpreted as the site already existing. If you run the command with --dest site_name it succeeds.

The best solution is probably to just take the site name provided by the user and make it lowercase before making the API request.

Copy/overwrite template rules on merge

I want to run a merge of site configuration. Currently, the merge will skip template rules that are already configured on the target site. However, I'd like the option to not skip, but overwrite the template rule.

Add ability to do a dry run

Add the ability to do a dry run to see what all changes will be made before running the command for real against a live site.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.