Skip to content

Commit 3532dc0

Browse files
author
Juliya Smith
authored
Chore/docs (#84)
1 parent cb86228 commit 3532dc0

32 files changed

+1239
-56
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ how a consumer would use the library (e.g. adding unit tests, updating documenta
6060

6161
- A progress bar that displays during bulk commands.
6262

63+
- Short option `-u` added for `code42 high-risk-employee add-risk-tags` and `remove-risk-tags`.
64+
6365
### Fixed
6466

6567
- Fixed bug in bulk commands where value-less fields in csv files were treated as empty strings instead of None.

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,25 @@ See class documentation on the [Command](src/code42cli/commands.py) class for an
122122
7. Each command accepts a `use_single_arg_obj` bool in its constructor. If set to true, this will instead cause the handler to be called with a single object
123123
containing all of the args as attributes, which will be passed to a variable named `args` in your handler. Since your handler will only contain the parameter `args`,
124124
the names of your cli parameters need to built manually in your `arg_customizer` if you use this option. An example of this can be seen in `code42cli.cmds.securitydata.main`.
125+
126+
127+
## Documentation
128+
129+
`code42cli` uses [Sphinx](http://www.sphinx-doc.org/) to generate documentation.
130+
131+
To build the documentation, run the following from the `docs` directory:
132+
133+
```bash
134+
make html
135+
```
136+
137+
To view the resulting documentation, open `docs/_build/html/index.html`.
138+
139+
For the best viewing experience, run a local server to view the documentation.
140+
You can this by running the below from the `docs` directory using python 3:
141+
142+
```bash
143+
python -m http.server --directory "_build/html" 1337
144+
```
145+
146+
and then pointing your browser to `localhost:1337`.

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ $ python setup.py install
2525

2626
First, create your profile:
2727
```bash
28-
code42 profile create MY_FIRST_PROFILE https://example.authority.com security.admin@example.com
28+
code42 profile create --name MY_FIRST_PROFILE --server example.authority.com --username security.admin@example.com
2929
```
3030

31-
Your profile contains the necessary properties for logging into Code42 servers.
32-
After running `code42 profile create`, the program prompts you about storing a password.
33-
If you agree, you are then prompted to input your password.
31+
Your profile contains the necessary properties for logging into Code42 servers. After running `code42 profile create`,
32+
the program prompts you about storing a password. If you agree, you are then prompted to input your password.
3433

35-
Your password is not shown when you do `code42 profile show`.
36-
However, `code42 profile show` will confirm that a password exists for your profile.
37-
If you do not set a password, you will be securely prompted to enter a password each time you run a command.
34+
Your password is not shown when you do `code42 profile show`. However, `code42 profile show` will confirm that a
35+
password exists for your profile. If you do not set a password, you will be securely prompted to enter a password each
36+
time you run a command.
3837

39-
For development purposes, you may need to ignore ssl errors. If you need to do this, use the `--disable-ssl-errors` option when creating your profile:
38+
For development purposes, you may need to ignore ssl errors. If you need to do this, use the `--disable-ssl-errors`
39+
option when creating your profile:
4040

4141
```bash
42-
code42 profile create MY_FIRST_PROFILE https://example.authority.com security.admin@example.com --disable-ssl-errors
42+
code42 profile create -n MY_FIRST_PROFILE -s https://example.authority.com -u security.admin@example.com --disable-ssl-errors
4343
```
4444

4545
You can add multiple profiles with different names and the change the default profile with the `use` command:
@@ -48,7 +48,12 @@ You can add multiple profiles with different names and the change the default pr
4848
code42 profile use MY_SECOND_PROFILE
4949
```
5050

51-
When the `--profile` flag is available on other commands, such as those in `security-data`, it will use that profile instead of the default one.
51+
When the `--profile` flag is available on other commands, such as those in `security-data`, it will use that profile
52+
instead of the default one. For example,
53+
54+
```bash
55+
code42 security-data print -b 2020-02-02 --profile MY_SECOND_PROFILE
56+
```
5257

5358
To see all your profiles, do:
5459

@@ -64,7 +69,8 @@ Using the CLI, you can query for security events and alerts and send them to thr
6469
* A file
6570
* A server, such as SysLog
6671

67-
The following examples pertain to security events, but can also be used for alerts by replacing `security-data` with `alerts`:
72+
The following examples pertain to security events, but can also be used for alerts by replacing `security-data` with
73+
`alerts`:
6874

6975
To print events to stdout, do:
7076

docs/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SOURCEDIR = .
8+
BUILDDIR = _build
9+
10+
# Put it first so that "make" without argument is like "make help".
11+
help:
12+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13+
14+
.PHONY: help Makefile
15+
16+
# Catch-all target: route all unknown targets to Sphinx using the new
17+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18+
%: Makefile
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/_static/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.wy-side-nav-search>div.version {
2+
color: #404040;
3+
}

docs/commands.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Commands
2+
3+
* [Profile](commands/profile.md)
4+
* [Security Data](commands/securitydata.md)
5+
* [Alerts](commands/alerts.md)
6+
* [Alert Rules](commands/alertrules.md)
7+
* [Departing Employee](commands/departingemployee.md)
8+
* [High Risk Employee](commands/highriskemployee.md)

docs/commands/alertrules.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Alert Rules
2+
3+
## add-user
4+
5+
Add a user to a given alert rule.
6+
7+
Arguments:
8+
* `--rule-id`: Observer ID of the rule to be updated.
9+
* `--username`, `-u` The username of the user to add to the alert rule.
10+
11+
Usage:
12+
```bash
13+
code42 alert-rules add-user --rule-id <rule-id> --username <username>
14+
```
15+
16+
## remove-user
17+
18+
Remove a user to a given alert rule.
19+
20+
Arguments:
21+
* `--rule-id`: Observer ID of the rule to be updated.
22+
* `--username`, `-u`: The username of the user to remove from the alert rule.
23+
24+
Usage:
25+
```bash
26+
code42 alert-rules remove-user --rule-id <rule-id> --username <username>
27+
```
28+
29+
## list
30+
31+
Fetch existing alert rules.
32+
33+
Usage:
34+
```bash
35+
code42 alert-rules list
36+
```
37+
38+
## show
39+
40+
Print out detailed alert rule criteria.
41+
42+
Arguments:
43+
* `rule-id`: Observer ID of the rule.
44+
45+
Usage:
46+
```bash
47+
code42 alert-rules show <rule-id>
48+
```
49+
50+
## bulk generate-template
51+
52+
Generate the necessary csv template for bulk actions.
53+
54+
Arguments:
55+
* `cmd`: The type of command the template will be used for. Available choices= [add, remove].
56+
57+
Usage:
58+
```bash
59+
code42 alert-rules bulk generate-template <cmd>
60+
```
61+
62+
## bulk add
63+
64+
Add users to alert rules. CSV file format: `rule_id,username`.
65+
66+
Arguments:
67+
* `file-name`: The path to the csv file with columns 'rule_id,username' for bulk adding users to the alert rule.
68+
69+
Usage:
70+
```bash
71+
code42 alert-rules bulk add <filename>
72+
```
73+
74+
## bulk remove
75+
76+
Remove users from alert rules. CSV file format: `rule_id,username`.
77+
78+
Arguments:
79+
* `file-name`: The path to the csv file with columns 'rule_id,username' for bulk removing users to the alert rule.
80+
81+
Usage:
82+
```bash
83+
code42 alert-rules bulk remove <filename>
84+
```

docs/commands/alerts.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Alerts
2+
3+
## Shared arguments
4+
5+
Search args are shared between `print`, `write-to`, and `send-to` commands.
6+
7+
* `advanced-query`: A raw JSON alerts query. Useful for when the provided query parameters do not satisfy your
8+
requirements. WARNING: Using advanced queries is incompatible with other query-building args.
9+
* `-b`, `--begin`: The beginning of the date range in which to look for alerts, can be a date/time in yyyy-MM-dd (UTC)
10+
or yyyy-MM-dd HH:MM:SS (UTC+24-hr time) format where the 'time' portion of the string can be partial
11+
(e.g. '2020-01-01 12' or '2020-01-01 01:15') or a short value representing days (30d), hours (24h) or minutes (15m)
12+
from current time.
13+
* `-e`, `--end`: The end of the date range in which to look for alerts, argument format options are the same as --begin.
14+
* `--severity`: Filter alerts by severity. Defaults to returning all severities.
15+
Available choices=['HIGH', 'MEDIUM', 'LOW']
16+
* `--state`: Filter alerts by state. Defaults to returning all states. Available choices=['OPEN', 'RESOLVED'].
17+
* `--actor`: Filter alerts by including the given actor(s) who triggered the alert. Args must match actor username
18+
exactly.
19+
* `--actor-contains`: Filter alerts by including actor(s) whose username contains the given string.
20+
* `--exclude-actor`: Filter alerts by excluding the given actor(s) who triggered the alert. Args must match actor
21+
username exactly.
22+
* `--exclude-actor-contains`: Filter alerts by excluding actor(s) whose username contains the given string.
23+
* `--rule-name`: Filter alerts by including the given rule name(s).
24+
* `--exclude-rule-name`: Filter alerts by excluding the given rule name(s).
25+
* `--rule-id`: Filter alerts by including the given rule id(s).
26+
* `--exclude-rule-id`: Filter alerts by excluding the given rule id(s).
27+
* `--rule-type`: Filter alerts by including the given rule type(s).
28+
Available choices=['FedEndpointExfiltration', 'FedCloudSharePermissions', 'FedFileTypeMismatch'].
29+
* `--exclude-rule-type`: Filter alerts by excluding the given rule type(s).
30+
Available choices=['FedEndpointExfiltration', 'FedCloudSharePermissions', 'FedFileTypeMismatch'].
31+
* `--description`: Filter alerts by description. Does fuzzy search by default.
32+
* `-f`, `--format` (optional): The format used for outputting file events. Available choices= [CEF,JSON,RAW-JSON].
33+
* `-i`, `--incremental` (optional): Only get file events that were not previously retrieved.
34+
35+
## print
36+
37+
Print file events to stdout.
38+
39+
Arguments:
40+
* search args (note that begin date is often required).
41+
42+
Usage:
43+
```bash
44+
code42 alerts print -b <begin-date> <args>
45+
```
46+
47+
## write-to
48+
49+
Write file events to the file with the given name.
50+
51+
Arguments:
52+
* `output_file`: The name of the local file to send output to.
53+
* search args (note that begin date is often required).
54+
55+
Usage:
56+
```bash
57+
code42 alerts write-to -b 2020-03-01 <rgs>
58+
```
59+
60+
## send-to
61+
62+
Send file events to the given server address.
63+
64+
Arguments:
65+
* `server`: The server address to send output to.
66+
* `protocol` (optional): Protocol used to send logs to server. Available choices= [TCP, UDP].
67+
* search args (note that begin date is often required).
68+
69+
Usage:
70+
```bash
71+
code42 alerts send-to <server> <optional-args> <args>
72+
```
73+
74+
## clear-checkpoint
75+
76+
Remove the saved file event checkpoint from 'incremental' (-i) mode.
77+
78+
Usage:
79+
```bash
80+
code42 alerts clear-checkpoint
81+
```

docs/commands/departingemployee.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Departing Employee
2+
3+
## add
4+
5+
Add a user to the departing-employee detection list.
6+
7+
Arguments:
8+
* `username`: A Code42 username for an employee.
9+
* `--cloud-alias` (optional): An alternative email address for another cloud service.
10+
* `--departure-date` (optional): The date the employee is departing in format yyyy-MM-dd.
11+
* `--notes` (optional): Notes about the employee.
12+
13+
Usage:
14+
```bash
15+
code42 departing-employee add <username> <optional-args>
16+
```
17+
18+
## remove
19+
20+
Remove a user from the departing-employee detection list.
21+
22+
Arguments:
23+
* `username`: A Code42 username for an employee.
24+
25+
Usage:
26+
```bash
27+
code42 departing-employee remove <username>
28+
```
29+
30+
## bulk generate-template
31+
32+
Generate the necessary csv template for bulk actions.
33+
34+
Arguments:
35+
* `cmd`: The type of command the template will be used for. Available choices= [add, remove].
36+
37+
Usage:
38+
```bash
39+
code42 departing-employee bulk generate-template <cmd>
40+
```
41+
42+
## bulk add
43+
44+
Bulk add users to the departing-employee detection list using a csv file.
45+
46+
Arguments:
47+
* `filename`: The path to the csv file for bulk adding users to the departing-employee detection list.
48+
49+
Usage:
50+
```bash
51+
code42 departing-employee bulk add <filename>
52+
```
53+
54+
## bulk remove
55+
56+
Bulk remove users from the departing-employee detection list using a file.
57+
58+
Arguments:
59+
* `users-file`: A file containing a line-separated list of users to remove form the departing-employee detection
60+
list.
61+
62+
Usage:
63+
```bash
64+
code42 departing-employee bulk remove <users-file>
65+
```

0 commit comments

Comments
 (0)