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
The command is useful for verifying URL structures.
47
47
48
+
## Security
49
+
Fetching resources from user-supplied URLs is an inherently dangerous operation and may
50
+
leave your application vulnerable to [server side request forgery](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery),
51
+
[path traversal](https://owasp.org/www-community/attacks/Path_Traversal), [denial of service](https://owasp.org/www-community/attacks/Denial_of_Service)
52
+
or other security flaws.
53
+
54
+
go-getter contains mitigations for some of these security issues, but should still be used with
55
+
caution in security-critical contexts. See the available [security options](#Security-Options) that
56
+
can be configured to mitigate some of these risks.
48
57
## URL Format
49
58
50
59
go-getter uses a single string URL as input to download from a variety of
@@ -361,3 +370,79 @@ In order to access to GCS, authentication credentials should be provided. More i
361
370
#### GCS Testing
362
371
363
372
The tests for `get_gcs.go` require you to have GCP credentials set in your environment. These credentials can have any level of permissions to any project, they just need to exist. This means setting `GOOGLE_APPLICATION_CREDENTIALS="~/path/to/credentials.json"` or `GOOGLE_CREDENTIALS="{stringified-credentials-json}"`. Due to this configuration, `get_gcs_test.go` will fail for external contributors in CircleCI.
373
+
374
+
375
+
### Security Options
376
+
377
+
**Disable Symlinks**
378
+
379
+
In your getter client config, we recommend using the `DisableSymlinks` option,
380
+
which prevents writing through or copying from symlinks (which may point outside the directory).
381
+
382
+
```go
383
+
client:= getter.Client{
384
+
// This will prevent copying or writing files through symlinks
385
+
DisableSymlinks: true,
386
+
}
387
+
```
388
+
389
+
**Disable or Limit `X-Terraform-Get`**
390
+
391
+
Go-Getter supports arbitrary redirects via the `X-Terraform-Get` header. This functionality
392
+
exists to support [Terraform use cases](https://www.terraform.io/language/modules/sources#http-urls),
393
+
but is likely not needed in most applications.
394
+
395
+
For code that uses the `HttpGetter`, add the following configuration options:
396
+
397
+
```go
398
+
varhttpGetter = &getter.HttpGetter{
399
+
// Most clients should disable X-Terraform-Get
400
+
// See the note below
401
+
XTerraformGetDisabled: true,
402
+
// Your software probably doesn’t rely on X-Terraform-Get, but
403
+
// if it does, you should set the above field to false, plus
404
+
// set XTerraformGet Limit to prevent endless redirects
405
+
// XTerraformGetLimit: 10,
406
+
}
407
+
```
408
+
409
+
**Enforce Timeouts**
410
+
411
+
The `HttpGetter` supports timeouts and other resource-constraining configuration options. The `GitGetter` and `HgGetter`
412
+
only support timeouts.
413
+
414
+
Configuration for the `HttpGetter`:
415
+
416
+
```go
417
+
varhttpGetter = &getter.HttpGetter{
418
+
// Disable pre-fetch HEAD requests
419
+
DoNotCheckHeadFirst: true,
420
+
421
+
// As an alternative to the above setting, you can
422
+
// set a reasonable timeout for HEAD requests
423
+
// HeadFirstTimeout: 10 * time.Second,
424
+
425
+
// Read timeout for HTTP operations
426
+
ReadTimeout: 30 * time.Second,
427
+
428
+
// Set the maximum number of bytes
429
+
// that can be read by the getter
430
+
MaxBytes: 500000000, // 500 MB
431
+
}
432
+
```
433
+
434
+
For code that uses the `GitGetter` or `HgGetter`, set the `Timeout` option:
0 commit comments