Skip to content

Commit 5714a26

Browse files
author
Horea Porutiu
authored
adding run_all script (#15)
1 parent 8314923 commit 5714a26

File tree

3 files changed

+58
-7
lines changed

3 files changed

+58
-7
lines changed

README.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Below are the steps needed to use the Discovery SDK.
1111

12-
# 👨🏻‍💻 Understanding the Setup Script 👨🏻‍💻
12+
# 👨🏻‍💻 Understanding the Setup Script 👩🏻‍💻
1313

1414
In order to speed up the development process, we've provided you with a script called
1515
`set_env_vars.sh` in the scripts folder to automate a few things needed to run the SDK.
@@ -32,7 +32,7 @@ The script accomplishes the following things using the following code:
3232
pip install -e ".[testing]"
3333
```
3434

35-
## 👨🏻‍💻 Adding Env Variables to Setup Script 👨🏻‍💻
35+
## 👨🏻‍💻 Adding Env Variables to Setup Script 👩🏻‍💻
3636

3737
🚨 At this point, you'll need to edit the `scripts/set_env_vars.sh` script in an editor of your choice 🚨
3838

@@ -69,7 +69,7 @@ export SLACK_DISCOVERY_SDK_TEST_USER_AUDIT_TOKEN='xoxp-*************'
6969
chmod +x scripts/set_env_vars.sh
7070
```
7171

72-
## 👨🏻‍💻 Run the Setup Script 👨🏻‍💻
72+
## 👩🏻‍💻 Run the Setup Script 👨🏻‍💻
7373
Use the following command to run the script:
7474

7575
> Note: you must use the `source` command so that the env variables are set properly.
@@ -109,22 +109,45 @@ You should see a response similar to the following (note the result below has be
109109
DEBUG:slack_discovery_sdk.base_client:Rate limit metrics: DEBUG:slack_discovery_sdk.base_client:Received the following response - status: 200, headers: {'date': 'Wed, 13 Oct 2021 22:09:57 GMT',..., body: {"ok":true,"enterprise":{"id":"T027****D2R","name":"Enterprise-****-Sandbox","domain":"test-****","email_domain":"","icon":...,"image_default":true},"is_verified":false,"teams":[{"id":"****","name":"Enterprise-****-Sandbox","domain":"test-****","email_domain":"","icon":{"image_102":"https:\/\/a...avatars-teams\/ava_0021-88.png","image_default":true},"is_verified":false,"enterprise_id":"E**","is_enterprise":0,"created":1625594757,"archived":false,"deleted":false,"discoverable":"unlisted"}]}}
110110
```
111111
112-
There are various other scripts in the `slack_discovery_sdk/examples` folder, with each script serving to solve a different use case. Below you can find some basic information about each script:
112+
If you want to run all of the examples at once, you can use the `run_all.sh` script.
113+
114+
> Note: before you can run this script, you will need to mark the file as executable with the following command:
115+
116+
```bash
117+
chmod +x scripts/run_all.sh
118+
```
119+
120+
Then, run the script:
121+
122+
```
123+
./scripts/run_all.sh
124+
```
125+
126+
This will run all of the examples in the `slack_discovery_sdk/examples` folder, and
127+
you should see debug output in your terminal once the script has finished running.
128+
129+
Continue reading below to learn what each example does:
113130
114131
💳 <b>`DLP_call_pattern.py`</b> 💳
115132
* This script involves using the tombstoning capabilities of the Discovery SDK to check for messages that contain sensitive information. If sensitive information is detected by our script (for example a credit card number), the message is tombstoned, and the user is notified that their message is being reviewed.
116133
* Once you run this script, you should see that one of your
117134
messages in the channel which you set in your env variable (SLACK_DISCOVERY_SDK_TEST_CHANNEL_ID) should have been tombstoned. The message should now say `This message is being scanned to make sure it complies with your team’s data security policies.`
118135
119-
🙋🏾‍♀️ <b>`user_based_eDiscovery_pattern.py`</b> 👩🏻‍🏫
136+
🙋🏾‍♀️ <b>`user_based_eDiscovery_with_edits.py`</b> 👩🏻‍🏫
120137
* This script retrieves all of the conversations (channels) and messages a particular user is in. It then outputs those
121-
conversations to a file, and stores them in the following format: `YYYY/MM/DD/user_id/channel_id/discovery_conversations_history.json`.
138+
conversations to a file, and stores them in the following format: `YYYY/MM/DD/user_id/channel_id/discovery_conversations.json`. If the `has_edits` flag is true
139+
for a certain conversation, all edited messages will be found in the `edits` field.
140+
122141
123142
👩🏻‍🏫 <b>`audit_logs_pattern.py`</b> 👩🏻‍🏫
124143
* This script will use the [Audit Logs API](https://api.slack.com/admins/audit-logs) to find all of the
125144
channels that a particular user has created. As is the
126145
case with the `user_based_eDiscovery` script, it will only
127-
be useful if you have a paricular user which you want to see details about. This script will output the channel creation events associated with a particular user_id to in the following format: `YYYY/MM/DD/user_id/audit_logs/public_channel_created.json`.
146+
be useful if you have a paricular user which you want to see details about. This script will output the channel creation events associated with a particular user_id to in the following format: `YYYY/MM/DD/user_id/audit_logs/public_channel_created.json`.
147+
148+
🙋🏾‍♀️ <b>`user_based_eDiscovery_pattern.py` (Without Edits) </b> 👩🏻‍🏫
149+
* This is the same as the `user_based_eDiscovery_with_edits.py` script, except it
150+
doesn't capture edits.
128151
129152
## Considerations
130153
The SDK and examples are to aid in your development process. Please feel free to use this as a learning exercise, and to build on top of these examples, but the examples shown above are by no means a complete solution.

scripts/run_all.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2021, Slack Technologies, LLC. All rights reserved.
2+
3+
#!/bin/sh
4+
5+
# run enterprise info
6+
python3 slack_discovery_sdk/examples/get_enterprise_info.py
7+
8+
# run DLP
9+
python3 slack_discovery_sdk/examples/DLP_call_pattern.py
10+
11+
# run eDiscovery without edits (commented out since we will be running pattern with edits)
12+
# python3 slack_discovery_sdk/examples/user_based_eDiscovery_pattern.py
13+
14+
# run eDiscovery
15+
python3 slack_discovery_sdk/examples/user_based_eDiscovery_with_edits.py
16+
17+
# run auditLogs
18+
python3 slack_discovery_sdk/examples/audit_logs_pattern.py

scripts/set_env_vars.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ python3 -m venv .venv
1212
source .venv/bin/activate
1313
echo "Success."
1414

15+
# Ensures pip is updated to the latest version
16+
echo "Updating pip"
17+
pip install -U pip
18+
echo "Sucessfully updated pip"
19+
20+
# Installs required packages and dependencies
21+
echo "Installing required packages"
22+
pip install -e ".[testing]"
23+
echo "Sucessfully installed required packages"
24+
1525
############# Needed to run SDK ####################################
1626
echo "Setting your SLACK_DISCOVERY_SDK_TEST_ENTERPRISE_TOKEN."
1727

0 commit comments

Comments
 (0)