You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: INSTALL.md
+36-23Lines changed: 36 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,42 @@
2
2
3
3
To get this Azure Function working, you need to:
4
4
5
-
1. create a GitHub App
6
-
2. create an Azure Function app, and deploy this Azure Function to it
7
-
3. configure the Azure Function with the GitHub App's private key, webhook secret, and the GitHub App's ID
8
-
4. configure the Azure Function with the Slack webhook URL
9
-
5. configure the GitHub App with the Azure Function's URL as the webhook
10
-
6. install the GitHub App on the organization and set it to be active on the whole organization or the repositories you want
5
+
1. create or edit a Slack App and get a webhook URL
6
+
2. create a GitHub App
7
+
3. create an Azure Function app, and deploy this Azure Function to it
8
+
4. configure the Azure Function with the GitHub App's private key, webhook secret, and the GitHub App's ID
9
+
5. configure the Azure Function with the Slack webhook URL
10
+
6. configure the GitHub App with the Azure Function's URL as the webhook
11
+
7. install the GitHub App on the organization and set it to be active on the whole organization or the repositories you want
11
12
12
13
> [!NOTE]
13
14
> When working with the Azure CLI, remember to use `az login` to log in to Azure, and `az logout` first if you are having problems.
14
15
15
16
> [!NOTE]
16
17
> To use the Bash (use WSL on Windows for Bash) scripts in the `scripts` directory, set your Azure settings in a `azure.env` file that they pick up from the same directory. You may need to change settings if you want to vary the region the Function is used in, or change its name to allow more than one to coexist in the same subscription.
17
18
19
+
> [!WARNING]
20
+
> Don't get confused between the Slack webhook and the Azure Function webhook.
21
+
>
22
+
> The Slack webhook is configured in the Azure Function, and the Azure Function webhook is configured in the GitHub App.
23
+
24
+
## Creating a Slack App and getting a webhook URL
25
+
26
+
You need to create a Slack App, and get a webhook URL for it. You can use the UI to do this.
27
+
28
+
### Use the Slack UI to create a new Slack App
29
+
30
+
1. Go to the [new Slack App page](https://api.slack.com/apps?new_app=1)
31
+
2. Choose the "From scratch" option
32
+
3. Name it something like "Secret Scanning Notifier", and choose the workspace you want to create it in
33
+
4. Click on the "Create App" button
34
+
35
+
Under "Add features and functionality", choose "Incoming Webhooks", and toggle the switch to "On".
36
+
37
+
Click on the "Add New Webhook to Workspace" button, and choose the channel you want to post to.
38
+
39
+
You will be given a new Slack webhook URL. Copy this and save it somewhere safe, as you will need it later to configure the Azure Function you will create.
40
+
18
41
## Creating a GitHub app
19
42
20
43
You need to create a GitHub app, and install it on a repo. You can use the UI to do this.
@@ -41,7 +64,7 @@ You will need a name, a description, a homepage URL (which can just be `https://
41
64
- uncheck the "Active" checkbox for the webhook, since we have not yet created the Azure Function
42
65
- use a secure secret for the webhook secret, since this authenticates that this GitHub App is making requests to your Functions App
43
66
- ⚠️ save the webhook secret somewhere safe, and generate it securely. It's best to do this using a password manager or key vault
44
-
- give the GitHub App read and write access to Actions under the repository permissions
67
+
- give the GitHub App read access to Secret scanning alerts under the repository permissions
45
68
- leave the option selected to "Enable SSL verification"
46
69
- click on the "Create GitHub App" button
47
70
@@ -52,12 +75,6 @@ Once it is created, you will need to download the private key.
52
75
53
76
[The full GitHub docs](https://docs.github.com/en/enterprise-cloud@latest/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) can help you if you get stuck.
54
77
55
-
### Use the GitHub API to create a new GitHub App
56
-
57
-
> **TODO**
58
-
59
-
This is possible [using a manifest](https://docs.github.com/en/enterprise-cloud@latest/apps/sharing-github-apps/registering-a-github-app-from-a-manifest), but has not yet been implemented here.
60
-
61
78
## Deploying the Azure Function
62
79
63
80
You need to create an Azure Function App, and deploy the Azure Function to it.
@@ -112,9 +129,11 @@ where `APP_ID` is the ID of the GitHub App you created earlier, `PRIVATE_KEY` is
112
129
The private key should be a single line, removing the whitespace in the `.pem` file, like:
You can use the `pem-to-one-liner.sh` script to do this, which just uses `tr` to remove the line breaks.
136
+
118
137
It is also possible to set these directly in the Azure Portal, but you may prefer to configure them in code.
119
138
120
139
#### Synchronizing the Functions App's settings with the local repo
@@ -192,6 +211,8 @@ There are a couple of ways to deploy the function to the Function App with the V
192
211
193
212
You need to find the URL of the Function to set up the GitHub App's webhook.
194
213
214
+
This is returned when you deploy the function to the Function App using the `deploy.sh` script. If you used a different method, you may need to find it manually.
215
+
195
216
You can use the Azure Portal, the Azure CLI, or the VSCode Azure Functions extension to do this.
196
217
197
218
If you can't find the Function under the Functions App, you may need to click on the "Refresh" button in the top menu. If that doesn't work, there may be an error in the Function's code or settings. Check that you can debug the Function locally, to see if there are any mistakes in the configuration, especially the `PRIVATE_KEY` setting.
@@ -218,7 +239,7 @@ Open up the Function App, and expand the Functions node. Right-click on the Func
218
239
219
240
Fill in the details you now know from the Function App and installed Function into the GitHub App's settings.
220
241
221
-
- select the `secret_scanning_alert` event under "Permissions & events"
242
+
- select the `secret_scanning_alert` event under "Permissions & events" and click "Save" at the bottom of the page
222
243
- ⚠️ carefully think about the security implications of giving the Functions App access to these events
223
244
- set the webhook URL to the URL of the Function
224
245
- set the webhook to Active by checking the box
@@ -232,11 +253,3 @@ You need to install the GitHub App on an organization or repository.
232
253
- navigate to the GitHub App you created earlier, and click on the "Install App" button
233
254
- choose which organization to install it on
234
255
- choose whether to install it for selected repositories, or for the whole organization
235
-
236
-
### Use the GitHub API to install the GitHub App
237
-
238
-
> **TODO**
239
-
240
-
This has not been implemented yet.
241
-
242
-
This is left until the creation of the app using a manifest has been implemented.
0 commit comments