Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Sync fork from stripe/smokescreen #1

Open
wants to merge 646 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
646 commits
Select commit Hold shift + click to select a range
b810127
log net.Conn errors on conn closes
cds2-stripe Apr 7, 2020
b4e1a2c
Merge pull request #104 from stripe/cds/log-conn-timeouts
cds2-stripe Apr 29, 2020
2835cf7
wait for a maximum of ExitTimeout when shutting down
cds2-stripe May 4, 2020
d8296d7
Merge pull request #105 from stripe/cds/wait-exit-timeout
cds2-stripe May 4, 2020
6902cc5
dont incorrectly strip x-smokescreen-error
cds2-stripe Mar 5, 2020
e094123
support custom error handling
cds2-stripe Mar 26, 2020
8aa5eb0
tests
cds2-stripe Mar 26, 2020
b1cc28c
comments, small cleanups
cds2-stripe Apr 1, 2020
849f9f0
fix tests
cds2-stripe Apr 1, 2020
201bc30
make net.Error more granular
cds2-stripe Apr 1, 2020
d04b82e
pr feedback
cds2-stripe Apr 23, 2020
5b6155c
more test fixes
cds2-stripe May 5, 2020
83e08aa
use github actions for ci
cds2-stripe May 6, 2020
8d8ba71
pr feedback
cds2-stripe May 6, 2020
9b2363f
Merge pull request #106 from stripe/cds/github-actions
cds2-stripe May 6, 2020
294416b
collection of small logging improvements
cds2-stripe May 11, 2020
de17c7c
go mod tidy; go mod vendor
cds2-stripe May 11, 2020
b532a08
log dst_ip and dst_port over remote_addr
cds2-stripe May 11, 2020
f6d545f
fix var names
cds2-stripe May 11, 2020
b20cc7c
Merge pull request #107 from stripe/cds/logging-improvements
cds2-stripe May 11, 2020
4cc1462
only emit active_at_termination if the conn is *not* idle
cds2-stripe May 11, 2020
c830df7
Merge pull request #108 from stripe/cds/fix-active-term-metric
cds2-stripe May 11, 2020
b9b7fe9
merge conflicts
cds2-stripe May 14, 2020
09af255
always log rejectResponse error message
cds2-stripe May 14, 2020
510cdc9
fix flaky test
cds2-stripe May 14, 2020
5b5884c
fixup integration tests
cds2-stripe May 14, 2020
003b149
fix test ip
cds2-stripe May 14, 2020
196c05f
use new request scoped logger
cds2-stripe May 14, 2020
507cde9
pr feedback
cds2-stripe May 15, 2020
1ad5d75
use .test tld
cds2-stripe May 15, 2020
393279a
do not double log deny errors
cds2-stripe May 15, 2020
c1ab53e
Merge pull request #100 from stripe/cds/fix-error-header-deletion
cds2-stripe May 19, 2020
94f824e
goproxy: don't synchronize on connections closing
cds2-stripe May 28, 2020
3e12c56
remove timed_out conn close log field
cds2-stripe May 29, 2020
e434930
add test for half-closing http servers
cds2-stripe May 29, 2020
e4e1168
add test for client half-close
cds2-stripe May 29, 2020
41bcfe0
run new integration test in ci
cds2-stripe May 29, 2020
773162f
fix data race in logging
cds2-stripe May 29, 2020
7ebd126
Merge pull request #111 from stripe/cds/close-after-copy
cds2-stripe May 29, 2020
c70e9d8
Log amount of time net.DialTimeout takes to establish the connection
anktjsh-stripe Jun 4, 2020
71fe862
Merge pull request #112 from stripe/anktjsh-smokescreen
anktjsh-stripe Jun 5, 2020
2c9c54e
Apply Yaml configuration options
anktjsh-stripe Jun 8, 2020
4099794
Merge pull request #114 from stripe/anktjsh-smokescreen
anktjsh-stripe Jun 9, 2020
b7071e6
add domain tag prefix
cds2-stripe Jun 10, 2020
42ca8b4
Merge pull request #115 from stripe/cds/tag-by-domain
cds2-stripe Jun 10, 2020
e2dd5e3
Add flag for proxy protocol if using smokescreen as a reverse proxy
anktjsh-stripe Jun 24, 2020
ea2750d
Fix markdown link typo in README.md for go modules
polybuildr Jul 8, 2020
4a2e15a
Merge pull request #117 from polybuildr/readme-fix-link
cds2-stripe Jul 9, 2020
d4f702b
Update to add custom function for dialer
anktjsh-stripe Jul 9, 2020
f437c9e
fix import issue
anktjsh-stripe Jul 9, 2020
e6872c9
fix typo
anktjsh-stripe Jul 9, 2020
4761e1a
passing in context as well to get source information
anktjsh-stripe Jul 10, 2020
1b56b22
testing custom dial timeout
anktjsh-stripe Jul 14, 2020
a4b011e
Merge pull request #116 from stripe/anktjsh-smokescreen
anktjsh-stripe Jul 14, 2020
fdce6d5
Update README with current help contents
alexmv Aug 31, 2020
d7f1a83
Fix logging of project in CANONICAL-PROXY-DECISION
rwg-stripe Aug 31, 2020
e2d3d38
Merge pull request #119 from stripe/rwg/project-logging.0
rwg-stripe Sep 2, 2020
74304c9
goproxy: don't log use of closed network connection errors
cds2-stripe Sep 2, 2020
906ef72
fix connect proxy timeout test relying on non-deterministic error check
cds2-stripe Sep 2, 2020
03edbdb
add comment about test behavior
cds2-stripe Sep 3, 2020
33955a3
Merge pull request #122 from stripe/cds/bump-goproxy-version
cds2-stripe Sep 3, 2020
9c2b299
Merge pull request #118 from alexmv/readme
hans-stripe Sep 3, 2020
b97b381
Switch to build-time configurable version
hans-stripe Sep 3, 2020
10e00e7
Bump to version 0.0.2
hans-stripe Sep 3, 2020
bf08251
Merge pull request #123 from stripe/hans-fix-build-version
hans-stripe Sep 3, 2020
e3c4ef8
Update comment about how graceful socket closing works
alexmv Aug 31, 2020
78149e7
Merge pull request #120 from alexmv/timeout-comment
cds2-stripe Sep 30, 2020
04d5d0c
update README badge to use github actions
jjiang-stripe Nov 10, 2020
307b05c
Merge pull request #124 from stripe/jjiang-update-badge
jjiang-stripe Nov 10, 2020
3afeb7c
Add code coverage steps
jjiang-stripe Nov 10, 2020
67a5434
Update deprecated usage of set-env
jjiang-stripe Nov 10, 2020
a7b1380
Merge pull request #125 from stripe/jjiang-goveralls
jjiang-stripe Nov 10, 2020
43960c4
Update tested Go versions to 1.14 and 1.15 (#129)
mattm-stripe Nov 30, 2020
a9a356d
Make smokescreen clean of staticcheck and gosimple lints (#130)
mattm-stripe Dec 7, 2020
dc59eb0
Bumping goproxy version to include support for upstream proxies (#132)
eastebry Dec 18, 2020
325d420
Log complete TCP tuples where possible
rwg-stripe Feb 1, 2021
cc6ff3d
Appease gofmt
rwg-stripe Feb 1, 2021
132fd94
Make reporting server error message more readable
rwg-stripe Feb 2, 2021
2209e5a
Include nanoseconds in default log timestamps
rwg-stripe Feb 2, 2021
eeaa285
Order fields alphabetically
rwg-stripe Feb 20, 2021
27e3513
Move einhorn to internal/einhorn
qaisjp Mar 12, 2021
0e6b9d2
Apply "go mod tidy"
qaisjp Mar 12, 2021
8712d15
Merge branch 'go-einhorn' into subtree-merge
qaisjp Mar 12, 2021
550993e
Rename import and re-apply "go mod tidy"
qaisjp Mar 12, 2021
8651207
Merge pull request #138 from qaisjp/subtree-merge
cds2-stripe Mar 12, 2021
18ba014
Upgrade tested Go versions for 1.16 Go release. (#136)
alexmv Mar 22, 2021
effeb92
Adding the ability to define a custom reject response handler (#137)
eastebry Mar 25, 2021
55bbe19
bump go mod version to 1.15
cds2-stripe Apr 14, 2021
37bbae4
Merge pull request #142 from stripe/cds/go-1.15
cds2-stripe Apr 14, 2021
0a6a877
use metrics wrapper to allow adding arbitrary tags
cds2-stripe Apr 14, 2021
feb26c2
go mod update/tidy
cds2-stripe Apr 14, 2021
af35dfd
add a few comments
cds2-stripe Apr 14, 2021
1c9778c
dont implicitly use a noop client if addr is nil
cds2-stripe Apr 14, 2021
2ece471
tests
cds2-stripe Apr 14, 2021
aedc70d
use noop metrics client when no addr is provided
cds2-stripe Apr 14, 2021
a7b6425
tag by slice
cds2-stripe Apr 15, 2021
c02051c
go mod vendor
cds2-stripe Apr 15, 2021
1c68f97
pr feedback
cds2-stripe Apr 15, 2021
b027f2f
copy metrics for noop client
cds2-stripe Apr 15, 2021
94fdcd4
add guard to prevent adding metrics after smokescreen has started
cds2-stripe Apr 15, 2021
834ba79
Merge pull request #143 from stripe/cds/smokescreen-metrics
cds2-stripe Apr 16, 2021
bfca45c
Merge pull request #135 from stripe/rwg/log-tcp-tuples.0
cds2-stripe Apr 19, 2021
b3a6912
Update documentation to remove mention of `X-Smokescreen-Role` (#141)
alexmv Jun 9, 2021
35ad8e0
Add coverage % badge (#128)
jjiang-stripe Jun 9, 2021
b89ae56
Allow private ranges default option (#140)
eastebry Jun 9, 2021
dc40301
allow ipv4 only dns lookups (#144)
cds2-stripe Jun 9, 2021
37438e8
CI matrix maintenance (#152)
ransford-stripe Dec 15, 2021
fafb6ae
improvements to ACL comparisons
ransford-stripe Nov 27, 2021
3f7a1b5
add self to contributor list
ransford-stripe Dec 15, 2021
be333a2
bump patch version
ransford-stripe Dec 15, 2021
55e6c91
add dns and tcp timing information to logs (#150)
cds2-stripe Dec 15, 2021
96dc8b0
Merge pull request #151 from ransford-stripe/ransford/globs
ransford-stripe Dec 15, 2021
dbb816b
bump goproxy to 3f1dfba6d1a4747c78fee7069e2f28fd6b703917 (#153)
cds2-stripe Mar 9, 2022
7ce24ba
Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8 (#154)
dependabot[bot] Apr 7, 2022
9a1fe37
Go 1.18 (#156)
cds2-stripe Apr 7, 2022
051b82e
Use constants for logger field names (#147)
folbricht-stripe Apr 7, 2022
8cb7e75
use tags to track success/fail connection attempt metrics
jjiang-stripe Apr 20, 2022
e589a2f
Merge pull request #157 from stripe/jjiang/tag-based-metrics
jjiang-stripe Apr 22, 2022
dea7b3c
Fix hostname parsing for square brackets
jjiang-stripe Apr 28, 2022
3ad120d
normalize the hostname before passing it down
jjiang-stripe Apr 28, 2022
e196cd6
Merge pull request #158 from stripe/jjiang/fix-hostname
jjiang-stripe May 4, 2022
7c55cad
log outbound remote addr at conn close (#159)
cds2-stripe Jun 1, 2022
ce4844c
Use Go 1.17 IP.IsPrivate() function.
alexmv Jun 11, 2022
caa186b
Merge pull request #160 from alexmv/private-ip
jjiang-stripe Jun 24, 2022
4087092
Strip all square brackets (#163)
jjiang-stripe Jul 6, 2022
777820e
Use Go-embedded binary version
lewandowski-stripe Jul 12, 2022
3592fff
Improve address normalization (#164)
lewandowski-stripe Jul 22, 2022
4675fea
Merge branch 'master' into lewandowski/version
lewandowski-stripe Jul 22, 2022
2133fbf
Merge pull request #165 from stripe/lewandowski/version
jjiang-stripe Jul 25, 2022
34cb22b
Use more strict check for CONNECT's host:port (#166)
lewandowski-stripe Jul 29, 2022
ba56465
Add feature to track connection success rate (#168)
cmoresco-stripe Aug 22, 2022
5b14275
report more detail on Dial errors
ransford-stripe Aug 2, 2022
b0702cb
move reportConnError to metrics.go
ransford-stripe Aug 3, 2022
25e5023
refactor: private statsdClient, MockMetricsClient
ransford-stripe Aug 3, 2022
2f3f1be
metrics_test: fix metric counter
ransford-stripe Aug 22, 2022
3fb1641
test metric values in dial timeout test
ransford-stripe Aug 22, 2022
2f15e42
test connection reset
ransford-stripe Aug 22, 2022
842c949
test that half closure results in success
ransford-stripe Aug 22, 2022
926c9fe
comments on {,New}MockMetricsClient
ransford-stripe Aug 22, 2022
ce3e4e0
sort
ransford-stripe Aug 22, 2022
2e2e15e
fix a backquote
ransford-stripe Aug 22, 2022
c56faa1
remove an odd quote
ransford-stripe Aug 22, 2022
c4e1bb7
add basic metrics tests
ransford-stripe Aug 22, 2022
66bb8d3
typo
ransford-stripe Aug 22, 2022
0ed1ab1
double-count tagged metric updates on purpose
ransford-stripe Aug 22, 2022
6f37c1a
Merge pull request #169 from ransford-stripe/ransford/metrics
ransford-stripe Aug 22, 2022
82175c4
Emit metrics from ConnSuccessRateTracker (#170)
cmoresco-stripe Aug 24, 2022
1422d01
tst
lewandowski-stripe Aug 24, 2022
9159411
Split hostport normalization to a separate package
lewandowski-stripe Aug 26, 2022
9c7e0cd
Remove normalize.go
lewandowski-stripe Aug 26, 2022
0d202e5
(test) Fix error checks
lewandowski-stripe Aug 26, 2022
ae8abaf
Use %w for error messages
lewandowski-stripe Aug 26, 2022
5df19e5
Simplify hostport initialization
lewandowski-stripe Aug 26, 2022
958320f
Create a Tracker interface so it can be mocked for testing (#171)
cmoresco-stripe Aug 26, 2022
3d746c9
Use new TrackerInterface in the smokescreen config (#173)
cmoresco-stripe Aug 29, 2022
4318207
Move metrics utilities into a package (#174)
cmoresco-stripe Aug 29, 2022
4e7fc2c
Fix failing tests
lewandowski-stripe Aug 30, 2022
7852655
Merge branch 'master' into lewandowski/normalize-pkg
lewandowski-stripe Aug 30, 2022
4b81968
Test the full range of supported Go versions (1.17-1.19)
lewandowski-stripe Aug 30, 2022
e3621df
`go mod tidy`
lewandowski-stripe Aug 30, 2022
6ff9bec
`go mod vendor`
lewandowski-stripe Aug 30, 2022
db6352a
Permit underscores in requested domain names
lewandowski-stripe Aug 30, 2022
b604c41
Merge pull request #172 from stripe/lewandowski/normalize-pkg
jjiang-stripe Aug 30, 2022
a260657
Merge pull request #177 from stripe/lewandowski/underscores
jjiang-stripe Aug 30, 2022
d00abba
emit metrics for connection overhead latency (#175)
cds2-stripe Aug 31, 2022
36675b5
Merge pull request #176 from stripe/lewandowski/github-actions
lewandowski-stripe Aug 31, 2022
462ad36
Normalize domains in ACL validation
jjiang-stripe Sep 20, 2022
ceab789
readme updates
jjiang-stripe Sep 20, 2022
5b7c3b7
Merge pull request #178 from stripe/jjiang/normalize-hosts-in-acl-val…
jjiang-stripe Sep 22, 2022
90e9012
Add VerifyRequestHandler config option (#180)
param-stripe Nov 29, 2022
1b14b4e
add resolver.lookup_time metric
ransford-stripe Nov 29, 2022
f98f253
include successful metric emission in TestProxyProtocols
ransford-stripe Nov 30, 2022
6f52008
copyedit mTLS bits
ransford-stripe Nov 30, 2022
75d4022
remove redundant Go version refs
ransford-stripe Nov 30, 2022
2b8b2a8
fix header
ransford-stripe Nov 30, 2022
8766738
instructions for local testing
ransford-stripe Nov 30, 2022
e67044e
typo
ransford-stripe Nov 30, 2022
f4fbd78
Merge pull request #182 from stripe/ransford-readme-updates
ransford-stripe Dec 1, 2022
4835f35
Merge pull request #181 from stripe/ransford-dns-query-time-metric
ransford-stripe Dec 1, 2022
abacfd9
Make hostMatchesGlob exportable
sergeyrud-stripe Feb 21, 2023
0c66af9
Merge pull request #185 from stripe/sergeyrud-make-hostMatchesGlob-ex…
sergeyrud-stripe Feb 22, 2023
e3e4397
add resolver.lookup_time metric
ransford-stripe Nov 29, 2022
fde9e33
include successful metric emission in TestProxyProtocols
ransford-stripe Nov 30, 2022
a102ad2
Make hostMatchesGlob exportable
sergeyrud-stripe Feb 21, 2023
ba85e02
update golang.org/x/net
ransford-stripe Feb 22, 2023
84e845d
update logrus and x/net/idna; sync vendor dir
ransford-stripe Feb 22, 2023
5664619
drop 1.17, 1.18 tests per README
ransford-stripe Feb 22, 2023
8005a94
go mod tidy
ransford-stripe Feb 22, 2023
83ed067
Merge pull request #186 from ransford-stripe/ransford-mod-update
ransford-stripe Feb 22, 2023
7c83eff
add a custom interface for the resolver instead of forcing *net.Resol…
JulesDT Apr 14, 2023
65b5bdb
feature/add prometheus metrics (#179)
jmcconnell26 May 19, 2023
aa75ca1
Use ElementsMatch to ignore order
kevinv-stripe May 24, 2023
31f4a3c
Just use require
kevinv-stripe May 24, 2023
c227b0d
Merge pull request #190 from stripe/kevinv/fix-test-map-keys
kevinv-stripe May 24, 2023
445d0d6
Move the custom request handler call after the main acl check
sergeyrud-stripe May 24, 2023
8dd3072
Merge pull request #189 from stripe/sergeyrud-move-custom-request-han…
kevinv-stripe May 31, 2023
604044b
Use local server instead of httpbin (#192)
cmoresco-stripe Jun 23, 2023
81a59fd
Do not return a denyError for DNS resolution failures (#194)
cds2-stripe Jul 13, 2023
6f13b30
add AcceptResponseHandler to modify accepted responses (#196)
cmoresco-stripe Jul 26, 2023
14a7af2
Update docs to clarify global_deny_list (#197)
cmoresco-stripe Jul 27, 2023
48069eb
Use AcceptResponseHandler in goproxy https CONNECT hook (#199)
cmoresco-stripe Aug 3, 2023
c86310d
Export SmokescreenContext type (#200)
cmoresco-stripe Aug 4, 2023
4bc8d89
generate new test pki (#206)
cds2-stripe Nov 7, 2023
d4766a6
allow listen address specification for prom (#203)
ne-bknn Nov 8, 2023
8cceb4f
Bump golang.org/x/net from 0.7.0 to 0.17.0 (#204)
dependabot[bot] Nov 8, 2023
997578a
bump go versions (#207)
cds2-stripe Nov 8, 2023
1a9dea7
update dependency
xieyuxi-stripe Nov 13, 2023
df2fa89
configure addr in smokescreen and add unit test
xieyuxi-stripe Nov 13, 2023
3f8bcc3
use fmt
xieyuxi-stripe Nov 14, 2023
413045a
try this workaround
xieyuxi-stripe Nov 14, 2023
892f9cb
variable name change
xieyuxi-stripe Nov 14, 2023
4cae3b1
Merge pull request #208 from stripe/xieyuxi-configurable-proxy-addrs
xieyuxi-stripe Nov 15, 2023
8c0fa26
Update docs to disambiguate ACL vs --deny-address behavior (#210)
cmoresco-stripe Dec 1, 2023
2457d2f
fix fields bug
jjiang-stripe Aug 4, 2023
bc280e3
remove extra field setting
jjiang-stripe Aug 4, 2023
24ee0c8
trigger build
jjiang-stripe Feb 15, 2024
fbd1ea7
Merge pull request #201 from stripe/jjiang/fix-logging-addrs
jjiang-stripe Feb 15, 2024
5c3d435
Add support for Smokescreen -> HTTPS CONNECT Proxy ACLs (#213)
pspieker-stripe Feb 16, 2024
3e74045
Bump goproxy version to incorporate CONNECT proxy header changes
pspieker-stripe Feb 16, 2024
44dbbfa
WIP
pspieker-stripe Feb 16, 2024
065ad0e
Merge pull request #215 from stripe/bump-gp-version
pspieker-stripe Feb 16, 2024
eb1ac09
Bump google.golang.org/protobuf from 1.28.1 to 1.33.0 (#216)
dependabot[bot] Apr 23, 2024
85c4c64
Add support for username / password auth in URLs to external CONNECT …
pspieker-stripe Jul 11, 2024
d593d0e
Ensure proxy passed in X-Upstream-Https-Proxy is parsable
gauthamw-stripe Sep 4, 2024
149b19d
Merge pull request #224 from stripe/gauthamw/https-proxy
gauthamw-stripe Sep 4, 2024
ac11203
Update Github build workflows (#228)
harold-stripe Sep 17, 2024
1477610
Use goveralls parallel build
harold-s Sep 17, 2024
735a6e8
Merge pull request #229 from stripe/harold/goveralls-build
harold-stripe Sep 17, 2024
506e362
go get -d github.com/stripe/goproxy@latest && go mod vendor
harold-s Sep 9, 2024
734c343
Add MITM support to Smokescreen
harold-s Sep 10, 2024
4e1b3e2
Use MitmTLSConfig in the config instead of MitmCa
harold-s Sep 12, 2024
ddde90f
PR feedback + remove CloseIdleConnections
harold-s Sep 13, 2024
92537ef
Refactor allowed_domains_mitm to mitm_domains
harold-s Sep 17, 2024
4cf6e0b
Rename ValidateRule
harold-s Sep 17, 2024
dab4bde
Merge pull request #225 from stripe/harold/mitm_support
harold-stripe Sep 17, 2024
3713647
Add Support for Reject Handler with Context
saurabhbhatia-stripe Oct 3, 2024
0c4798d
Update comment
saurabhbhatia-stripe Oct 4, 2024
b3a45df
Block smokescreen init incase of invalid config
saurabhbhatia-stripe Oct 4, 2024
97f1857
fix: fix slice init length
cuishuang Oct 4, 2024
04ce070
Remove duplicate validation
saurabhbhatia-stripe Oct 8, 2024
f6f8191
Merge pull request #232 from stripe/saurabhbhatia/add-reject-handler
saurabhbhatia-stripe Oct 8, 2024
bc38d13
Make SmokeScreen Fields Public
saurabhbhatia-stripe Oct 10, 2024
a6b1a34
Revert Role fixes
saurabhbhatia-stripe Oct 10, 2024
c75cffb
Revert Role fixes
saurabhbhatia-stripe Oct 10, 2024
688e70b
Merge pull request #234 from stripe/saurabhbhatia/smokescreen-ctx-cha…
saurabhbhatia-stripe Oct 11, 2024
9556eb9
Update goproxy version to v0.0.0-20241017101008-e12ef0653f22 (#235)
saurabhbhatia-stripe Oct 17, 2024
5b0cc7a
Adding [allow|deny]_addresses settings to yaml config file
eastebry Oct 18, 2024
523d927
Update goproxy version to v0.0.0-20241022131412-58117846327a (#238)
saurabhbhatia-stripe Oct 23, 2024
1c315f8
Merge pull request #237 from eastebry/master
jjiang-stripe Nov 4, 2024
bffe947
Merge pull request #233 from cuishuang/master
jjiang-stripe Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on: [push, pull_request]
name: Test
# Workaround for coveralls error "Can't add a job to a build that is already closed"
# See https://github.com/lemurheavy/coveralls-public/issues/1716
env:
COVERALLS_SERVICE_NUMBER: ${{ github.run_id }}-${{ github.run_attempt }}
COVERALLS_PARALLEL: true
jobs:
test:
strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Setup env
run: |
echo "{GOFLAGS}={-mod=vendor}" >> $GITHUB_ENV
- name: Vet
run: |
go vet -v ./...
- name: Test
run: |
go mod verify
go test -race -v -timeout 2m -failfast -covermode atomic -coverprofile=.covprofile ./... -tags=nointegration
# Run integration tests hermetically to avoid nondeterministic races on environment variables
go test -race -v -timeout 2m -failfast ./cmd/... -run TestSmokescreenIntegration
go test -race -v -timeout 2m -failfast ./cmd/... -run TestInvalidUpstreamProxyConfiguratedFromEnv
go test -race -v -timeout 2m -failfast ./cmd/... -run TestInvalidUpstreamProxyConfiguration
go test -race -v -timeout 2m -failfast ./cmd/... -run TestClientHalfCloseConnection
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=.covprofile -service=github
finish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Close goveralls parallel build
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=.covprofile -service=github -parallel-finish=true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
*~
/smokescreen
*.swp
*.swo
*.swn
*debug.test*
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "smokescreen",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "./",
"args": ["--config-file", "config.yaml", "--egress-acl-file", "acl.yaml"]
}
]
}
308 changes: 308 additions & 0 deletions Development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@

# Development and Testing

## Testing
```bash
go test ./...
```

## Running locally

This section describes how to run Smokescreen locally with different scenarios and using `curl` as a client.

- [HTTP Proxy](#http-proxy)
- [HTTP CONNECT Proxy](#http-connect-proxy)
- [Monitor metrics Smokescreen emits](#monitor-metrics-smokescreen-emits)
- [HTTP CONNECT Proxy over TLS](#http-connect-proxy-over-tls)
- [MITM (Man in the middle) Proxy](#mitm-man-in-the-middle-proxy)
- [MITM (Man in the middle) Proxy over TLS](#mitm-man-in-the-middle-proxy-over-tls)

### HTTP Proxy

#### Configurations

```yaml
# config.yaml
---
allow_missing_role: true # skip mTLS client validation (use default ACL)
```

```yaml
# acl.yaml
---
version: v1
services: []
default:
name: default
project: security
action: enforce
allowed_domains:
- example.com
```

#### Run

```bash
# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl
curl -x localhost:4750 http://example.com
# Curl with ALL_PROXY
ALL_PROXY=localhost:4750 curl -v http://example.com
```

### HTTP CONNECT Proxy

#### Configurations

```yaml
# config.yaml
---
allow_missing_role: true # skip mTLS client validation (use default ACL)
```

```yaml
# acl.yaml
---
version: v1
services: []
default:
name: default
project: security
action: enforce
allowed_domains:
- api.github.com
```

#### Run

```bash
# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl
curl --proxytunnel -x localhost:4750 https://api.github.com/zen
# Curl with HTTPS_PROXY
HTTPS_PROXY=localhost:4750 curl https://api.github.com/zen
```

### Monitor metrics Smokescreen emits

#### Configurations

```yaml
# config.yaml
---
allow_missing_role: true # skip mTLS client validation (use default ACL)
statsd_address: 127.0.0.1:8200
```

```yaml
# acl.yaml
---
version: v1
services: []
default:
name: default
project: security
action: enforce
allowed_domains:
- api.github.com
```

#### Run

```bash
# Listen to a local port with nc (in a different shell)
nc -uklv 127.0.0.1 8200

# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl
curl --proxytunnel -x localhost:4750 https://api.github.com/zen
# Curl with HTTPS_PROXY
HTTPS_PROXY=localhost:4750 curl https://api.github.com/zen
```

### HTTP CONNECT Proxy over TLS

#### Set-up

##### Generate certificates
```bash
mkdir -p mtls_setup
# Private keys for CAs
openssl genrsa -out mtls_setup/server-ca.key 2048
openssl genrsa -out mtls_setup/client-ca.key 2048

# Generate client and server CA certificates
openssl req -new -x509 -nodes -days 1000 -key mtls_setup/server-ca.key -out mtls_setup/server-ca.crt \
-subj "/C=AQ/ST=Petrel Island/L=Dumont-d'Urville
/O=Penguin/OU=Publishing house/CN=server CA"

openssl req -new -x509 -nodes -days 1000 -key mtls_setup/client-ca.key -out mtls_setup/client-ca.crt \
-subj "/C=MA/ST=Tarfaya/L=Tarfaya/O=Fennec/OU=Aviator/CN=Client CA"

# Generate a certificate signing request (client CN is localhost which is used by smokescreen as the service name by default)
openssl req -newkey rsa:2048 -nodes -keyout mtls_setup/server.key -out mtls_setup/server.req \
-subj "/C=AQ/ST=Petrel Island/L=Dumont-d'Urville/O=Chionis/OU=Publishing house/CN=server req"
openssl req -newkey rsa:2048 -nodes -keyout mtls_setup/client.key -out mtls_setup/client.req \
-subj "/C=MA/ST=Tarfaya/L=Tarfaya/O=Addax/OU=Writer/CN=localhost"

# Have the CA sign the certificate requests and output the certificates.
echo "authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = localhost
" > mtls_setup/localhost.ext

openssl x509 -req -in mtls_setup/server.req -days 1000 -CA mtls_setup/server-ca.crt -CAkey mtls_setup/server-ca.key -set_serial 01 -out mtls_setup/server.crt -extfile mtls_setup/localhost.ext

openssl x509 -req -in mtls_setup/client.req -days 1000 -CA mtls_setup/client-ca.crt -CAkey mtls_setup/client-ca.key -set_serial 01 -out mtls_setup/client.crt
```

##### Configurations

```yaml
# config.yaml
---
tls:
cert_file: "mtls_setup/server.crt"
key_file: "mtls_setup/server.key"
client_ca_files:
- "mtls_setup/client-ca.crt"
```

```yaml
# acl.yaml
---
version: v1
services:
- name: localhost
project: github
action: enforce
allowed_domains:
- api.github.com
default:
name: default
project: security
action: enforce
allowed_domains: []
```

#### Run

```bash
# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl
curl --proxytunnel -x https://localhost:4750 --proxy-cacert mtls_setup/server-ca.crt --proxy-cert mtls_setup/client.crt --proxy-key mtls_setup/client.key https://api.github.com/zen
# Curl with HTTPS_PROXY
HTTPS_PROXY=https://localhost:4750 curl --proxy-cacert mtls_setup/server-ca.crt --proxy-cert mtls_setup/client.crt --proxy-key mtls_setup/client.key https://api.github.com/zen
```

### MITM (Man in the middle) Proxy

#### Set-up

```yaml
# config.yaml
---
allow_missing_role: true # skip mTLS client validation (use default ACL)
# Re-using goproxy library CA and key
mitm_ca_cert_file: "vendor/github.com/stripe/goproxy/ca.pem"
mitm_ca_key_file: "vendor/github.com/stripe/goproxy/key.pem"
```

```yaml
# acl.yaml
---
version: v1
services: []
default:
name: default
project: security
action: enforce
allowed_domains:
- wttr.in
mitm_domains:
- domain: wttr.in
add_headers:
Accept-Language: el
detailed_http_logs: true
detailed_http_logs_full_headers:
- User-Agent
```

#### Run

```bash
# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl (weather should be in Greek since we set the Accept-Language header)
curl --proxytunnel -x localhost:4750 --cacert vendor/github.com/stripe/goproxy/ca.pem https://wttr.in
# Curl with HTTPS_PROXY
HTTPS_PROXY=localhost:4750 curl --cacert vendor/github.com/stripe/goproxy/ca.pem https://wttr.in
```

### MITM (Man in the middle) Proxy over TLS

#### Set-up

Please generate the certificates from the TLS Generate certificates section.

```yaml
# config.yaml
---
tls:
cert_file: "mtls_setup/server.crt"
key_file: "mtls_setup/server.key"
client_ca_files:
- "mtls_setup/client-ca.crt"
# Re-using goproxy library CA and key
mitm_ca_cert_file: "vendor/github.com/stripe/goproxy/ca.pem"
mitm_ca_key_file: "vendor/github.com/stripe/goproxy/key.pem"
```

```yaml
# acl.yaml
---
version: v1
services:
- name: localhost
project: github
action: enforce
allowed_domains:
- wttr.in
mitm_domains:
- domain: wttr.in
add_headers:
Accept-Language: el
detailed_http_logs: true
detailed_http_logs_full_headers:
- User-Agent
default:
name: default
project: security
action: enforce
allowed_domains: []
```

#### Run

```bash
# Run smokescreen (in a different shell)
go run . --config-file config.yaml --egress-acl-file acl.yaml

# Curl (weather should be in Greek since we set the Accept-Language header)
curl --proxytunnel -x https://localhost:4750 --cacert vendor/github.com/stripe/goproxy/ca.pem --proxy-cacert mtls_setup/server-ca.crt --proxy-cert mtls_setup/client.crt --proxy-key mtls_setup/client.key https://wttr.in
# Curl with HTTPS_PROXY
HTTPS_PROXY=https://localhost:4750 curl --cacert vendor/github.com/stripe/goproxy/ca.pem --proxy-cacert mtls_setup/server-ca.crt --proxy-cert mtls_setup/client.crt --proxy-key mtls_setup/client.key https://wttr.in
```
Loading