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: README.md
+36-29
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,7 @@ Semgrep will help you create a configuration file tailored to your Semgrep deplo
48
48
**Do not** share the value of `inbound.wireguard.privateKey`. This is your organization's private key. Reach out to Semgrep on Slack if you need to rotate your Wireguard keys.
49
49
50
50
Example:
51
+
51
52
```yaml
52
53
inbound:
53
54
wireguard:
@@ -67,18 +68,20 @@ inbound:
67
68
The `httpClient` configuration section modifies the HTTP client used for proxying requests.
68
69
69
70
Example:
71
+
70
72
```yaml
71
73
inbound:
72
74
httpClient:
73
75
additionalCACerts:
74
-
- /path/to/custom/cert.pem
76
+
- /path/to/custom/cert.pem
75
77
```
76
78
77
79
### GitHub
78
80
79
81
The `github` configuration section simplifies granting Semgrep access to leave PR comments.
80
82
81
83
Example:
84
+
82
85
```yaml
83
86
inbound:
84
87
github:
@@ -90,6 +93,7 @@ Under the hood, this config adds these allowlist items:
90
93
91
94
- GET `https://github.example.com/api/v3/repos/:owner/:repo`
92
95
- GET `https://github.example.com/api/v3/repos/:owner/:repo/pulls`
96
+
- GET `https://github.example.com/api/v3/orgs/:org/installation`
93
97
- POST `https://github.example.com/api/v3/repos/:owner/:repo/pulls/:number/comments`
94
98
- POST `https://github.example.com/api/v3/repos/:owner/:repo/issues/:number/comments`
95
99
@@ -98,6 +102,7 @@ Under the hood, this config adds these allowlist items:
98
102
Similarly, the `gitlab` configuration section grants Semgrep access to leave MR comments.
99
103
100
104
Example:
105
+
101
106
```yaml
102
107
inbound:
103
108
gitlab:
@@ -115,12 +120,12 @@ Under the hood, this config adds these allowlist items:
115
120
- PUT `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions/:discussion/notes/:note`
116
121
- PUT `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions/:discussion`
117
122
118
-
119
123
### Allowlist
120
124
121
125
The `allowlist` configuration section provides finer-grained control over what HTTP requests are allowed to be forwarded out of the broker. The first matching allowlist item is used. No allowlist match means the request will not be proxied.
122
126
123
127
Examples:
128
+
124
129
```yaml
125
130
inbound:
126
131
allowlist:
@@ -135,7 +140,6 @@ inbound:
135
140
methods: [GET]
136
141
setRequestHeaders:
137
142
Authorization: "Bearer ...snip..."
138
-
139
143
```
140
144
141
145
### Real-world example
@@ -144,22 +148,22 @@ Here's an example of allowing PR comments for a GitHub Enterprise instance hoste
@@ -169,11 +173,12 @@ The `logging` configuration section allows you to set additional logging options
169
173
```yaml
170
174
inbound:
171
175
logging:
172
-
logRequestBody: false # If true, the contents of any proxied HTTP request matching the allowlist will be logged in the request_body field in the proxy.request event
173
-
logResponseBody: false # If true, the contents of any proxied HTTP response will be logged in the response_body field in the proxy.response event
176
+
logRequestBody: false # If true, the contents of any proxied HTTP request matching the allowlist will be logged in the request_body field in the proxy.request event
177
+
logResponseBody: false # If true, the contents of any proxied HTTP response will be logged in the response_body field in the proxy.response event
174
178
```
175
179
176
180
Here's an example log output of `curl -X POST -H "Content-Type: application/json" "https://httpbin.org/anything" -d '{"foo": "bar"}'` being proxied through the network broker:
Multiple config files can be overlaid on top of each other by passing multiple `-c` args (ex. `semgrep-network-broker -c config1.yaml -c config2.yaml -c config3.yaml`). Note that while maps will be merged together, arrays will be _replaced_.
206
211
207
212
Requirements:
213
+
208
214
- internet access to `wireguard.semgrep.dev` on UDP port 51820
209
215
210
216
## Other Commands
@@ -222,6 +228,7 @@ Requirements:
222
228
`semgrep-network-broker pubkey`generates a base64 public key for a given private key (via stdin)
223
229
224
230
### relay
231
+
225
232
`semgrep-network-broker relay`launches an HTTP server that relays request that match a certain rule.
226
233
227
234
```yaml
@@ -232,7 +239,7 @@ outbound:
232
239
destinationUrl: https://httpbin.org/anything
233
240
jsonPath: "$.foo"
234
241
equals:
235
-
- bar
242
+
- bar
236
243
```
237
244
238
245
would result in requests addressed to http://localhost:8080/relay/test being relayed to https://httpbin.org/anything as long as the result of the jsonpath query `$.foo` executed on the request body results in the string `bar`.
@@ -249,9 +256,9 @@ outbound:
249
256
destinationUrl: https://httpbin.org/anything
250
257
jsonPath: "$.foo"
251
258
equals:
252
-
- bar
259
+
- bar
253
260
additionalConfigs:
254
-
- destinationUrl: htttps://example.com/fallback
261
+
- destinationUrl: htttps://example.com/fallback
255
262
```
256
263
257
-
The example above would relay traffic to https://httpbin.org/anything if the request body contains `{"foo": "bar"}`, otherwise, it'd relay traffic to `htttps://example.com/fallback`.
264
+
The example above would relay traffic to https://httpbin.org/anything if the request body contains `{"foo": "bar"}`, otherwise, it'd relay traffic to `htttps://example.com/fallback`.
0 commit comments