Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regex to redact sensitive IP data #137

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/fixtures/DEMO.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
http_interactions:
- request:
method: get
uri: http://ipinfo.io/
body:
encoding: ''
string: ''
headers:
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: 200
category: Success
reason: OK
message: 'Success: (200) OK'
headers:
access-control-allow-origin: '*'
content-encoding: gzip
content-type: application/json; charset=utf-8
date: Fri, 04 Oct 2024 01:00:32 GMT
referrer-policy: strict-origin-when-cross-origin
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
content-length: '247'
via: 1.1 google
strict-transport-security: max-age=2592000; includeSubDomains
body:
encoding: ''
file: no
string: |-
{
"ip": "redacted",
"hostname": "redacted",
"city": "Wellington",
"region": "Wellington Region",
"country": "NZ",
"loc": "-41.2866,174.7756",
"org": "redacted",
"postal": "6021",
"timezone": "Pacific/Auckland",
"readme": "https://ipinfo.io/missingauth"
}
recorded_at: 2024-10-04 01:00:32 GMT
recorded_with: vcr/1.6.0, webmockr/0.9.0
6 changes: 6 additions & 0 deletions tests/testthat/helper-vcr.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
library("vcr") # *Required* as vcr is set up on loading
invisible(vcr::vcr_configure(
filter_sensitive_data = list("<<<redacted>>>" = Sys.getenv('EBIRD_KEY')),
# Remove sensitive information about tester from cassettes
filter_sensitive_data_regex = list(
'"ip": "redacted"' = '"ip": "[0-9.]+"',
'"hostname": "redacted"' = '"hostname": "[^"]*"',
'"org": "redacted"' = '"org": "[^"]*"'
),
dir = vcr::vcr_test_path("fixtures")
))
vcr::check_cassette_names()
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-DEMO.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vcr::use_cassette("DEMO", {
test_that("DEMO", {
getlatlng()
})
})
Loading