Skip to content
Closed
Show file tree
Hide file tree
Changes from 192 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
da55bbf
CBG-4487: Avoid deadlock in revision cache between Get and On demand …
gregns1 Jan 29, 2025
150702a
CBG-4494 do not put documents into rev cache for an on demand import …
torcolvin Jan 29, 2025
6624d30
Remove single duplicate test always (#7332)
torcolvin Jan 29, 2025
5088a15
CBG-4478 switch database to offline if there is an error on synchrono…
torcolvin Jan 30, 2025
2df936b
CBG-4475: pick up gocbcore panic fix (#7337)
gregns1 Jan 30, 2025
9e94257
CBG-4507 create 3.1.12 builds (#7344)
torcolvin Jan 31, 2025
8a9c7f2
CBG-4499: fix leaking goroutines (#7335)
gregns1 Jan 31, 2025
81ef5b7
CBG-4450: test flake where nanoseconds are the same in the config bet…
gregns1 Jan 31, 2025
d102ae2
CBG-4180 update websocket library to 1.8.12 (#7341)
torcolvin Jan 31, 2025
98f9478
CBG-4501 define DatabaseLogCtx earlier (#7340)
torcolvin Jan 31, 2025
a74dad8
CBG-4312 improve metrics documentation (#7309)
torcolvin Jan 31, 2025
b77c0b4
CBG-4453: Retry index creation for longer (#7347)
gregns1 Feb 3, 2025
24b96f2
CBG-4510 fix exception when using -vv (#7350)
torcolvin Feb 4, 2025
65c5ae4
Add automated formatting for python (#7349)
torcolvin Feb 4, 2025
dccc524
CBG-4462: Avoid leaking ISGR StatsReporter goroutine underneath recon…
bbrks Feb 5, 2025
916ada2
CBG-4390: provide cluster UUID at top level endpoint (#7345)
gregns1 Feb 6, 2025
4bf79d0
CBG-4391: bubble up errors from startup db process to db summaries (#…
gregns1 Feb 6, 2025
d764940
CBG-4186: Put ISGR into an errored stopped state when a reconnect tim…
bbrks Feb 7, 2025
1398e96
CBG-4511: observability errors for online process (#7367)
gregns1 Feb 7, 2025
5932254
Bump golang.org/x/oauth2 from 0.25.0 to 0.26.0 (#7372)
dependabot[bot] Feb 10, 2025
dab84da
Bump golang.org/x/crypto from 0.32.0 to 0.33.0 (#7371)
dependabot[bot] Feb 10, 2025
4c7aa06
CBG-4519 wait for database online to prevent test panic (#7373)
torcolvin Feb 10, 2025
22d6fd3
CBG-4520 wait for stat to avoid test flake (#7375)
torcolvin Feb 10, 2025
44d6aa5
Shorten the time it takes to process bucket pool (#7356)
torcolvin Feb 10, 2025
3368f84
CBG-3838 fix TestAttachmentDeleteOnExpiry flake (#7368)
torcolvin Feb 11, 2025
5331552
CBG-4512: pick up gocb fix for bucket names with . in (#7376)
gregns1 Feb 11, 2025
aaa9f01
Require 3 collections to run adminapitest (#7377)
torcolvin Feb 12, 2025
a2b142b
Don't cancel builds on main (#7374)
torcolvin Feb 13, 2025
962b132
CBG-4454: Add Database Init and Online fatal error stats (#7369)
bbrks Feb 13, 2025
4cfd8b2
Add debug logging for flaky tests (#7383)
torcolvin Feb 15, 2025
2b3c9d5
Bump golang.org/x/net from 0.34.0 to 0.35.0 (#7385)
dependabot[bot] Feb 18, 2025
9314432
CBG-4533 track blip replication goroutines (#7384)
torcolvin Feb 18, 2025
f449497
CBG-4513 remove query based resync code (#7359)
torcolvin Feb 21, 2025
96b6c09
Bump github.com/couchbase/gocb/v2 from 2.9.4-0.20250206113323-8ef6d90…
dependabot[bot] Feb 24, 2025
a6fa584
CBG-4513 make sure db is online before running new requests (#7390)
torcolvin Feb 24, 2025
26d18f4
Bump github.com/KimMachineGun/automemlimit from 0.7.0 to 0.7.1 (#7394)
dependabot[bot] Feb 24, 2025
8e96423
CBG-4400 re-enable skipped attachment tests (#7389)
torcolvin Feb 24, 2025
80c5dbc
CBG-4371 Make sure not to redact profiles (#7351)
torcolvin Feb 25, 2025
779766e
Bump github.com/go-jose/go-jose/v4 from 4.0.4 to 4.0.5 (#7397)
dependabot[bot] Feb 25, 2025
5cef02b
refactor blip test client (#7398)
torcolvin Feb 25, 2025
cfcc0fe
CBG-4528 remove PushRevWithHistory (#7400)
torcolvin Feb 26, 2025
4962557
CBG-1196 uptake go-blip to make messages.flags atomic (#7396)
torcolvin Feb 26, 2025
ce9cc0f
CBG-4527 deflake TestOnDemandImportBlipFailure (#7401)
torcolvin Feb 27, 2025
a3f15bd
CBG-4528 remove separate doc lock and seq lock (#7402)
torcolvin Feb 27, 2025
31dab98
CBG-4452 avoid checking revpos on attachments (#7382)
torcolvin Mar 1, 2025
40a9126
CBG-4547: send deletions on blip test client (#7408)
gregns1 Mar 7, 2025
66c96bc
CBG-4552 switch go mod to include major.minor.patch (#7411)
torcolvin Mar 7, 2025
65abcd8
Bump golang.org/x/oauth2 from 0.26.0 to 0.28.0 (#7412)
dependabot[bot] Mar 7, 2025
6178c13
Bump golang.org/x/net from 0.35.0 to 0.37.0 (#7414)
dependabot[bot] Mar 10, 2025
11fc0f3
CBG-4536 prevent status goroutine leak if there is a fatal error (#7409)
torcolvin Mar 11, 2025
00f92b4
CBG-4553 fix race condition in TestBlipProveAttachmentV2Push (#7417)
torcolvin Mar 11, 2025
5c0a4c1
CBG-4290 drop logging for non metadata mutations on collection 0 (#7418)
torcolvin Mar 12, 2025
590383e
CBG-4549: Refactor resync Init so the reason for a reset is always lo…
bbrks Mar 12, 2025
e6311d8
CBG-4322 use unique output files (#7352)
torcolvin Mar 14, 2025
11907b9
Always use ClusterOnlyN1QLStore in tests (#7421)
torcolvin Mar 14, 2025
90dc97b
CBG-4560 mark always replicator reconnecting (#7419)
torcolvin Mar 14, 2025
4fe1928
CBG-4562 do not return invalid sessions with GET (#7420)
torcolvin Mar 14, 2025
8dc42b8
Bump github.com/coreos/go-oidc/v3 from 3.12.0 to 3.13.0 (#7425)
dependabot[bot] Mar 17, 2025
1fb9f8e
Speed up tests that include sleep (#7427)
torcolvin Mar 18, 2025
80b1092
CBG-4086 add assert to GetDocumentSequence (#7426)
torcolvin Mar 20, 2025
a110b1a
unit test: increase time slightly to account for slow machines (#7430)
torcolvin Mar 20, 2025
ddf7356
CBG-4550: Skip revcache insertion for all imports (#7431)
bbrks Mar 25, 2025
76cb1ce
CBG-4187: Add stat to track number of assertion failures (#7127)
bbrks Mar 25, 2025
3ae7e5c
CBG-4534: Wrap CORS origin warning in err check (#7433)
bbrks Mar 25, 2025
45cbed0
CBG-4570: stop audit events logging when no audit config is provided …
gregns1 Mar 25, 2025
5bd0d64
CBG-4572: pick up go-blip goroutine leak fix (#7434)
gregns1 Mar 25, 2025
1feef02
CBG-4503 use natural language for openapi (#7437)
torcolvin Mar 27, 2025
06ce005
CBG-4540: Clone byte slices coming over DCP when transforming into `s…
bbrks Mar 27, 2025
0afb808
CBG-4578: have maximum threshold for releasing sequences in nextSeque…
gregns1 Mar 28, 2025
0e9740a
CBG-4548 allow creation of partitioned indexes (#7428)
torcolvin Mar 28, 2025
55b5c52
CBG-4503 fix small grammar issues (#7441)
torcolvin Mar 28, 2025
777ea20
3.2.2.1 build (#7435)
bbrks Apr 1, 2025
7e432e8
CBG-4584: Return Invalid JSON error via OIDC discovery (#7438)
bbrks Apr 2, 2025
8d04c0f
CBG-4597 pass through network= parameters (#7457)
torcolvin Apr 3, 2025
6340aa8
CBG-4539 refactor replicatortest code (#7456)
torcolvin Apr 3, 2025
e304b82
CBG-4596 bump go version to 1.24.2 (#7459)
torcolvin Apr 3, 2025
80989bc
Add 3.2.4 builds (#7460)
bbrks Apr 3, 2025
c49bc31
CBG-4581 - Add sequence value stats for last allocated and last reser…
bbrks Apr 3, 2025
2e1f2e6
CBG-4546: Detect loading non-xattr config document in xattr bootstrap…
bbrks Apr 3, 2025
e0d757d
Bump golang.org/x/net from 0.37.0 to 0.38.0 (#7445)
dependabot[bot] Apr 4, 2025
fe43458
Bump golang.org/x/crypto from 0.36.0 to 0.37.0 (#7472)
dependabot[bot] Apr 7, 2025
580e727
CBG-2835 add wait for stat (#7466)
torcolvin Apr 7, 2025
89d8767
CBG-4602: benchmarking for procesEntry (#7474)
gregns1 Apr 11, 2025
0cee031
fix end of stats test format (#7480)
gregns1 Apr 14, 2025
fcab352
increase timeout for windows (#7482)
torcolvin Apr 14, 2025
3d3d3c7
CBG-4599 update to golanci-lint v2 configs (#7463)
torcolvin Apr 15, 2025
5eed596
Improve docs readability/errors (#7484)
torcolvin Apr 15, 2025
36d1329
Replace `[Type]Ptr` and `[Type]Default` usages with generic versions …
bbrks Apr 15, 2025
a82bd93
CBG-4604 document missing run states (#7476)
torcolvin Apr 16, 2025
bec2afd
Make `MgmtRequest` tolerant to request failures and not panic (#7486)
bbrks Apr 17, 2025
ef6eb2a
CBG-4456 limit user_xattr_key to 15 characters (#7487)
torcolvin Apr 22, 2025
9bf5858
CBG-4456 fix unit test (#7494)
torcolvin Apr 23, 2025
878e228
CBG-4613 switch option from serverless to principal index specific (#…
torcolvin Apr 23, 2025
6a56d7e
CBG-4006: Default log retention of 90 days for stats (#7493)
bbrks Apr 23, 2025
6e80b06
CBG-4603 Send 422 on delta sync for _removed in body (#7475)
torcolvin Apr 23, 2025
59d2fce
CBG-4603 use correct Ptr function (#7497)
torcolvin Apr 24, 2025
8552094
CBG-4575 switch allowConflicts default to false (#7488)
torcolvin Apr 24, 2025
177ab51
CBG-4616 make WaitForChanges more strict (#7489)
torcolvin Apr 24, 2025
01fe761
Disable TestChangesLargeSequence (#7495)
torcolvin Apr 24, 2025
61b742a
CBG-4587: Add async index init REST API to allow partitioned index cr…
bbrks Apr 28, 2025
d87f30e
CBG-4622 add test debug logging (#7506)
torcolvin Apr 28, 2025
a27fe98
CBG-4497 centralize blip correlation ids (#7498)
torcolvin Apr 29, 2025
cd228ab
CBG-4621 add wait for stat update (#7503)
torcolvin Apr 29, 2025
b217065
CBG-4619: skip assigning nil body attachments to _attachments propert…
gregns1 May 1, 2025
7663600
CBG-4614 Add toggle for using separate principal indexes (#7499)
torcolvin May 1, 2025
9e159de
DOC-11383 clarify use of admin_channels with collection_access (#7473)
torcolvin May 1, 2025
08b3998
Force golangci-lint to flag all errcheck issues (#7509)
torcolvin May 2, 2025
a75d50c
CBG-4626: setup 3.2.5 builds (#7510)
gregns1 May 2, 2025
d639bb1
Bump golang.org/x/oauth2 from 0.28.0 to 0.29.0 (#7470)
dependabot[bot] May 2, 2025
72b2aae
CBG-4615 decide when to use syncDocs or separate principal indexes (…
torcolvin May 5, 2025
56a5d26
CBG-4605: dcp mode for caching tool (#7483)
gregns1 May 7, 2025
0197e57
Bump github.com/KimMachineGun/automemlimit from 0.7.1 to 0.7.2 (#7512)
dependabot[bot] May 7, 2025
af676f3
refactor post upgrade tests (#7513)
torcolvin May 7, 2025
cb348a8
Allow RetryLoop to be type safe (#7514)
torcolvin May 7, 2025
fd7baef
Make tests work with views=true,xattrs=false (#7500)
torcolvin May 8, 2025
ad9c2bc
CBG-4607: Allow separate principal index creation using the async ind…
bbrks May 9, 2025
4afbcbc
CBG-4637 fix example for /_all_dbs (#7518)
torcolvin May 9, 2025
c44d299
CBG-4565 re-implement post_upgrade (#7516)
torcolvin May 9, 2025
94499e5
fix processEntry mode on caching tool (#7515)
gregns1 May 12, 2025
b60dbef
CBG-4633 avoid reconstructing channel map (#7524)
torcolvin May 12, 2025
2c6aa31
CBG-4632 increase allocation to account for * channel (#7527)
torcolvin May 13, 2025
7456780
CBG-4635: move getNextSequence() call to outside recent sequence loop…
gregns1 May 13, 2025
beaea48
CBG-4222: add unused sequence flag to log entry (#7529)
gregns1 May 13, 2025
c109db3
CBG-4631 remove duplicated calls to channels.NewID (#7523)
torcolvin May 13, 2025
bce69fd
CBG-4650 Use /db/_config offline= for persistent config in tests (#7531)
torcolvin May 15, 2025
2090d8e
CBG-4634: remove mutex around initial sequence inside getInitialSeque…
gregns1 May 16, 2025
b650fd4
CBG-4441 switch cache to use int64 from time.Time (#7526)
torcolvin May 16, 2025
ee1d13e
Bump golang.org/x/crypto from 0.37.0 to 0.38.0 (#7522)
dependabot[bot] May 19, 2025
7d271db
Bump golang.org/x/oauth2 from 0.29.0 to 0.30.0 (#7521)
dependabot[bot] May 19, 2025
61d763b
CBG-4472 remove warnings for null document bodies (#7538)
torcolvin May 22, 2025
35845eb
CBG-4658: Uptake Otto stack depth limit with tests (#7539)
bbrks May 23, 2025
a1fdf23
CBG-4617: Add DisablePublicAllDocs db config option (#7540)
bbrks May 27, 2025
bce353a
CBG-4662: Rescope log collection context to avoid deep context value …
bbrks May 29, 2025
f99c0ea
CBG-4666: Make /db/role/foo endpoint return a Content-Type header for…
bbrks May 29, 2025
92ccc63
CBG-4652: add missing unused sequence flag for unused sequences in Do…
gregns1 May 29, 2025
4840326
CBG-560 Remove unused DCP backfill status code (#7532)
torcolvin May 30, 2025
1870837
CBG-4629 add documentation for changes_request_plus (#7550)
torcolvin Jun 3, 2025
cf72677
CBG-4636: have check for skipped sequences on recent sequence handlin…
gregns1 Jun 3, 2025
2c5d56b
CBG-4680 remove cobertura (#7560)
torcolvin Jun 4, 2025
ba08531
CBG-4638 add missing require_resync to docs (#7556)
torcolvin Jun 4, 2025
b1d0d4e
CBG-603: have broadcast goroutine with ticker value to broadcast chan…
gregns1 Jun 5, 2025
e5e57dd
CBG-4669: Silence resync-specific logging (move to trace) (#7558)
bbrks Jun 5, 2025
c0782ae
Docs/API: Fix outdated 'keyspace_map' ISGR collections config referen…
bbrks Jun 5, 2025
b68fb7c
DOC-12510 add rules to enforce additional typechecking (#7548)
torcolvin Jun 6, 2025
2aaf83f
CBG-4563 add import_feed_processed_count stat (#7557)
torcolvin Jun 6, 2025
bda423c
CBG-4306: Log a warning when we're abandoning each skipped sequence e…
bbrks Jun 6, 2025
a732609
CBG-4661: Pass doc type down from ProcessFeedEvent to avoid extra key…
gregns1 Jun 6, 2025
aa77c86
Skip TestImportRollbackMultiplePartitions if vbucket count not 1024 (…
bbrks Jun 6, 2025
2b91802
CBG-4065: ISGR and Blipsync User-Agent support (#7563)
bbrks Jun 9, 2025
3609402
CBG-4683: add done chan for broadcast changes (#7565)
gregns1 Jun 9, 2025
6d03b0d
CBG-4670: only update xattr on import (#7555)
gregns1 Jun 9, 2025
9b2a445
Clarify sgcollect output (#7569)
torcolvin Jun 9, 2025
9903d24
Set up manifests for 3.2.4.1 and 3.2.5.1 (#7568)
adamcfraser Jun 10, 2025
e87c43e
CBG-4676: add stats around the public all docs endpoint (#7576)
gregns1 Jun 11, 2025
b29cf87
CBG-4664: Add Resync Metrics (#7577)
bbrks Jun 11, 2025
c737063
CBG-4678: reject writes when unsupported option is set for skipped se…
gregns1 Jun 11, 2025
80945e2
CBG-4684 remove dead/broken code (#7574)
torcolvin Jun 11, 2025
0f885d7
CBG-4688: Bump Go version and stdlib/x modules (#7578)
bbrks Jun 11, 2025
f9a996c
CBG-4351: Use Skiplist for Skipped Sequence storage (#7546)
gregns1 Jun 12, 2025
4820395
CBG-4691: Start 3.2.6 builds (#7583)
bbrks Jun 13, 2025
364322a
Test only: Use DefaultQueryPaginationLimit in as fallback in Principa…
bbrks Jun 13, 2025
e3b6e9b
Improve resync test assertion reliability (#7586)
bbrks Jun 13, 2025
e46771e
Fix Sync Gateway 3.3 index documentation (#7584)
torcolvin Jun 13, 2025
bd972bc
improve shared_bucket_access documentation (#7588)
torcolvin Jun 16, 2025
02c4297
Improvements for ISGR docs. (#7581)
torcolvin Jun 16, 2025
670839b
CBG-4473: Reset Resync on resume when changing collections (#7587)
bbrks Jun 16, 2025
0bf4737
CBG-4554 ask cbgt to perform a reconnect after rollback (#7589)
torcolvin Jun 16, 2025
c3ddd08
CBG-4493: Optimize happy-path for collections that have all indexes o…
bbrks Jun 18, 2025
5dacfb0
CBG-4693: close done chan in correct location (#7592)
gregns1 Jun 20, 2025
92cfc7c
CBG-4697: panic handler for import feed events (#7598)
gregns1 Jun 23, 2025
40758ca
Add Copilot code reivew instructions (#7599)
bbrks Jun 23, 2025
454f8d3
Add uv lock and mypy to do checking (#7597)
torcolvin Jun 23, 2025
eed8a89
CBG-3935: return error for invalid sync data in import codepath (#7582)
gregns1 Jun 23, 2025
222a29a
CBG-4686 increase wait time for windows/race (#7600)
torcolvin Jun 23, 2025
7593dfe
CBG-4689 ensure all indexes are deleted (#7602)
torcolvin Jun 24, 2025
6b0d541
CBG-4674 mark DropIndex error as retryable (#7603)
torcolvin Jun 24, 2025
910c3d3
CBG-4712 /_sgcollect_info endpoint to work with non default port (#7601)
torcolvin Jun 24, 2025
ac4581d
CBG-4687 have sgcollect_info use a token (#7604)
torcolvin Jun 24, 2025
d8f6cfe
CBG-3561 make --sync-gateway-password obsolete (#7605)
torcolvin Jun 26, 2025
f4d69af
CBG-4717: Tune down skiplist levels (#7608)
bbrks Jun 26, 2025
192681b
CBG-4716: remove repeated calls to was skipped in processEntry (#7606)
gregns1 Jun 26, 2025
aed0635
CBG-4718: log when setting reject writes unsupported option (#7609)
gregns1 Jun 26, 2025
7e1c899
CBG-2835: TestActiveReplicatorPullSkippedSequence stop after WaitForS…
bbrks Jun 26, 2025
f0155e0
CBG-4713 wait for stat for import (#7607)
torcolvin Jun 26, 2025
cde6f67
CBG-4705: Branch release/3.3.0 and disable main (#7613)
bbrks Jun 30, 2025
04d59d8
CBG-4704: anemone merge into main
gregns1 Jul 7, 2025
96f9f1d
test fixes
gregns1 Jul 8, 2025
9da2290
remove comment
gregns1 Jul 8, 2025
8b7f8e3
purge fix
gregns1 Jul 8, 2025
30ba324
test fix for TestBlipClientSendDelete
gregns1 Jul 8, 2025
4ac2637
Run goimports
torcolvin Jul 9, 2025
71379f0
pass golangci-lint
torcolvin Jul 9, 2025
1d46a0d
Remove prints
torcolvin Jul 10, 2025
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
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
When performing a code review, if there are any changes to the REST APIs (e.g. REST handler code, query parameters, structs returned via handler functions), ensure the OpenAPI specifications are updated accordingly in the `docs/api` directory.

When performing a code review, if there is any dev-time logging using `log.Printf`, `fmt.Printf`, or similar, ensure it is removed or replaced with appropriate Sync Gateway logging (e.g. `base.Infof`, `base.Warnf`, `base.Debugf`).

When performing a code review, if a log message includes User Data, ensure the value is wrapped with the `base.UD()` helper function to enable redaction. User Data includes: Document IDs, JSON document contents (keys and values), usernames, email addresses, or other personally identifiable information (PII).

When performing a code review, be mindful of performance implications, such as mutex contention, race conditions, and other concurrency-related issues.

When performing a code review, ensure code comments explain the *intent* or *reasoning* behind an implementation, rather than just restating what the code does.

When performing a code review, ensure `for` loops have sufficient exit conditions and are not prone to infinite loops. Prefer expressing the exit condition in the loop declaration itself, rather than relying on `break` statements within the loop body.
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,13 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-github-actions-annotate-failures pytest-httpserver trustme
- uses: astral-sh/setup-uv@v6
- name: Run test
run: |
pytest
uv run -- pytest
- name: Run mypy
run: |
uv run -- mypy

test-stats-definition-exporter:
runs-on: ${{ matrix.os }}
Expand All @@ -182,3 +178,13 @@ jobs:
- name: Run Tests
run: go test -shuffle=on -timeout=5m -count=1 -json -v "./tools/stats-definition-exporter" | tee test.json | jq -s -jr 'sort_by(.Package,.Time) | .[].Output | select (. != null )'
shell: bash
cache_perf_tool_build:
runs-on: ubuntu-latest
name: build cache perf tool
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24.4
- name: Build
run: go build "./tools/cache_perf_tool"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ verbose*.xml
sync_gateway
*.pb.gz
__pycache__
tools/cache_perf_tool/cache_perf_tool
cache_perf_tool
tools/stats-definition-exporter/stats-definition-exporter
stats-definition-exporter

### Couchbase Plugin ###
.cbcache/
Expand Down
6 changes: 5 additions & 1 deletion .redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ apis:

plugins:
- './docs/api/plugins/plugin.js'
- './docs/api/plugins/rules.js'

extends:
- minimal
- recommended-strict
rules:
# disable unnecessary/invalid warnings
operation-2xx-response: off # _blipsync 101 Upgrade ...
operation-4xx-response: off # do not require a 4xx response
operation-summary: off # Optional field
no-ambiguous-paths: off # /{db}/{doc} != /_debug/expvar
no-identical-paths: off # /{db} != /{targetdb}
no-path-trailing-slash: off # Some endpoints require a trailing slash
security-defined: off # TODO: Denote public and authenticated API endpoints with https://redocly.com/docs/cli/rules/security-defined
custom-rules/typecheck-defaults: error
custom-rules/check-additional-properties-names: error
4 changes: 2 additions & 2 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func (auth *Authenticator) AuthenticateTrustedJWT(token string, provider *OIDCPr
var identity *Identity
if provider.AllowUnsignedProviderTokens {
// Verify claims - ensures that the token we received from the provider is valid for Sync Gateway
identity, err = VerifyClaims(token, base.StringDefault(provider.ClientID, ""), provider.Issuer)
identity, err = VerifyClaims(token, base.ValDefault(provider.ClientID, ""), provider.Issuer)
if err != nil {
base.InfofCtx(auth.LogCtx, base.KeyAuth, "Error verifying raw token in AuthenticateTrustedJWT: %v", err)
return nil, PrincipalConfig{}, time.Time{}, err
Expand Down Expand Up @@ -913,7 +913,7 @@ func (auth *Authenticator) authenticateJWTIdentity(identity *Identity, provider
}

updates = PrincipalConfig{
Name: base.StringPtr(username),
Name: base.Ptr(username),
Email: &identity.Email,
JWTIssuer: &common.Issuer,
JWTRoles: jwtRoles,
Expand Down
34 changes: 17 additions & 17 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,11 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx))

var callbackURLFunc OIDCCallbackURLFunc
callbackURL := base.StringPtr("http://comcast:4984/_callback")
callbackURL := base.Ptr("http://comcast:4984/_callback")
providerGoogle := oidcProviderForTest(t, &OIDCProvider{
Name: "Google",
JWTConfigCommon: JWTConfigCommon{
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Issuer: issuerGoogleAccounts,
},
CallbackURL: callbackURL,
Expand Down Expand Up @@ -859,7 +859,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
},
AllowUnsignedProviderTokens: true,
})
Expand Down Expand Up @@ -891,7 +891,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
},
})
err = provider.InitUserPrefix(ctx)
Expand Down Expand Up @@ -920,7 +920,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud4"),
ClientID: base.Ptr("aud4"),
},
})
err = provider.InitUserPrefix(ctx)
Expand Down Expand Up @@ -949,7 +949,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud4"),
ClientID: base.Ptr("aud4"),
},
})
err = provider.InitUserPrefix(ctx)
Expand Down Expand Up @@ -977,7 +977,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
},
})
err = provider.InitUserPrefix(ctx)
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Register: true,
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
},
})
err = provider.InitUserPrefix(ctx)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Register: true,
},
})
Expand Down Expand Up @@ -1068,7 +1068,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Register: true,
},
})
Expand Down Expand Up @@ -1102,7 +1102,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
UserPrefix: strings.ToLower(providerGoogle.Name),
Register: true,
},
Expand Down Expand Up @@ -1143,7 +1143,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
UserPrefix: strings.ToLower(providerGoogle.Name),
Register: true,
},
Expand Down Expand Up @@ -1178,7 +1178,7 @@ func TestAuthenticateTrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
UserPrefix: strings.ToLower(providerGoogle.Name),
Register: true,
},
Expand Down Expand Up @@ -1290,20 +1290,20 @@ func TestAuthenticateUntrustedJWT(t *testing.T) {

issuerFacebookAccounts := "https://accounts.facebook.com"
issuerAmazonAccounts := "https://accounts.amazon.com"
callbackURL := base.StringPtr("http://comcast:4984/_callback")
callbackURL := base.Ptr("http://comcast:4984/_callback")
var callbackURLFunc OIDCCallbackURLFunc
providerGoogle := oidcProviderForTest(t, &OIDCProvider{
Name: "Google",
JWTConfigCommon: JWTConfigCommon{
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Issuer: issuerGoogleAccounts,
},
CallbackURL: callbackURL,
})
providerFacebook := oidcProviderForTest(t, &OIDCProvider{
Name: "Facebook",
JWTConfigCommon: JWTConfigCommon{
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Issuer: issuerFacebookAccounts,
},
CallbackURL: callbackURL,
Expand Down Expand Up @@ -1415,7 +1415,7 @@ func TestAuthenticateUntrustedJWT(t *testing.T) {
Name: providerGoogle.Name,
JWTConfigCommon: JWTConfigCommon{
Issuer: issuerGoogleAccounts,
ClientID: base.StringPtr("aud1"),
ClientID: base.Ptr("aud1"),
Register: true,
},
})
Expand Down
2 changes: 1 addition & 1 deletion auth/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (l *LocalJWTAuthProvider) verifyToken(ctx context.Context, token string, _
ClientID: *l.ClientID,
SkipClientIDCheck: *l.ClientID == "",
SupportedSigningAlgs: l.Algorithms,
SkipExpiryCheck: base.BoolDefault(l.SkipExpiryCheck, false),
SkipExpiryCheck: base.ValDefault(l.SkipExpiryCheck, false),
})

idToken, err := verifier.Verify(ctx, token)
Expand Down
6 changes: 3 additions & 3 deletions auth/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ func TestJWTVerifyToken(t *testing.T) {
ctx := base.TestCtx(t)
common := JWTConfigCommon{
Issuer: testIssuer,
ClientID: base.StringPtr(testClientID),
ClientID: base.Ptr(testClientID),
}
baseProvider := LocalJWTAuthConfig{
JWTConfigCommon: common,
Algorithms: []string{"RS256", "ES256"},
Keys: []jose.JSONWebKey{testRSAJWK, testECJWK, testEncRSAJWK},
SkipExpiryCheck: base.BoolPtr(true),
SkipExpiryCheck: base.Ptr(true),
}.BuildProvider(ctx, "test")
providerWithExpiryCheck := LocalJWTAuthConfig{
JWTConfigCommon: common,
Algorithms: []string{"RS256", "ES256"},
Keys: []jose.JSONWebKey{testRSAJWK, testECJWK, testEncRSAJWK},
SkipExpiryCheck: base.BoolPtr(false),
SkipExpiryCheck: base.Ptr(false),
}.BuildProvider(ctx, "test")

t.Run("garbage", test(baseProvider, "INVALID", anyError))
Expand Down
9 changes: 5 additions & 4 deletions auth/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
func (opm OIDCProviderMap) GetProviderForIssuer(ctx context.Context, issuer string, audiences []string) *OIDCProvider {
base.DebugfCtx(ctx, base.KeyAuth, "GetProviderForIssuer with issuer: %v, audiences: %+v", base.UD(issuer), base.UD(audiences))
for _, provider := range opm {
clientID := base.StringDefault(provider.ClientID, "")
clientID := base.ValDefault(provider.ClientID, "")
if provider.Issuer == issuer && clientID != "" {
// Iterate over the audiences looking for a match
for _, aud := range audiences {
Expand Down Expand Up @@ -310,7 +310,7 @@
}

config := oauth2.Config{
ClientID: base.StringDefault(op.ClientID, ""),
ClientID: base.ValDefault(op.ClientID, ""),
RedirectURL: *op.CallbackURL,
}

Expand Down Expand Up @@ -405,7 +405,7 @@
for i := 1; i <= maxRetryAttempts; i++ {
provider, err = oidc.NewProvider(GetOIDCClientContext(op.InsecureSkipVerify), op.Issuer)
if err == nil && provider != nil {
verifier = provider.Verifier(&oidc.Config{ClientID: base.StringDefault(op.ClientID, "")})
verifier = provider.Verifier(&oidc.Config{ClientID: base.ValDefault(op.ClientID, "")})
if err = provider.Claims(&metadata); err != nil {
base.ErrorfCtx(ctx, "Error caching metadata from standard issuer-based discovery endpoint: %s", base.UD(discoveryURL))
}
Expand Down Expand Up @@ -517,6 +517,7 @@
}

if err := base.JSONUnmarshal(bodyBytes, &metadata); err != nil {
err = base.ErrInvalidJSON
base.InfofCtx(ctx, base.KeyAuth, "Error parsing body during discovery sync: %v", err)
return ProviderMetadata{}, MaxProviderConfigSyncInterval, false, err
}
Expand Down Expand Up @@ -565,7 +566,7 @@
if len(signingAlgorithms.unsupportedAlgorithms) > 0 {
base.InfofCtx(ctx, base.KeyAuth, "Found algorithms not supported by underlying OpenID Connect library: %v", signingAlgorithms.unsupportedAlgorithms)
}
config := &oidc.Config{ClientID: base.StringDefault(op.ClientID, "")}
config := &oidc.Config{ClientID: base.ValDefault(op.ClientID, "")}
if len(signingAlgorithms.supportedAlgorithms) > 0 {
config.SupportedSigningAlgs = signingAlgorithms.supportedAlgorithms
}
Expand Down Expand Up @@ -653,7 +654,7 @@
// Returns an error if issuer is not present, returns an empty []string when audience is not present.
func getIssuerWithAudience(token *jwt.JSONWebToken) (issuer string, audiences []string, err error) {
claims := &jwt.Claims{}
err = token.UnsafeClaimsWithoutVerification(claims)

Check failure

Code scanning / CodeQL

Missing JWT signature check High

This JWT is parsed without verification and received from
this user-controlled source
.
if err != nil {
return issuer, audiences, pkgerrors.Wrapf(err, "failed to parse JWT claims")
}
Expand Down
10 changes: 5 additions & 5 deletions auth/oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestInitOIDCClient(t *testing.T) {
JWTConfigCommon: JWTConfigCommon{
Issuer: "http://127.0.0.1:12345/auth",
},
CallbackURL: base.StringPtr("http://127.0.0.1:12345/callback"),
CallbackURL: base.Ptr("http://127.0.0.1:12345/callback"),
})
err := provider.initOIDCClient(ctx)
require.Error(t, err, "openid connect client with unavailable issuer")
Expand All @@ -256,10 +256,10 @@ func TestInitOIDCClient(t *testing.T) {
t.Run("initialize openid connect client with valid provider config", func(t *testing.T) {
provider := oidcProviderForTest(t, &OIDCProvider{
JWTConfigCommon: JWTConfigCommon{
ClientID: base.StringPtr("foo"),
ClientID: base.Ptr("foo"),
Issuer: "https://accounts.google.com",
},
CallbackURL: base.StringPtr("http://sgw-test:4984/_callback"),
CallbackURL: base.Ptr("http://sgw-test:4984/_callback"),
})
err := provider.initOIDCClient(ctx)
require.NoError(t, err, "openid connect client with unavailable issuer")
Expand All @@ -270,10 +270,10 @@ func TestConcurrentSetConfig(t *testing.T) {
providerLock := sync.Mutex{}
provider := oidcProviderForTest(t, &OIDCProvider{
JWTConfigCommon: JWTConfigCommon{
ClientID: base.StringPtr("foo"),
ClientID: base.Ptr("foo"),
Issuer: "https://accounts.google.com",
},
CallbackURL: base.StringPtr("http://sgw-test:4984/_callback"),
CallbackURL: base.Ptr("http://sgw-test:4984/_callback"),
})

ctx := base.TestCtx(t)
Expand Down
15 changes: 12 additions & 3 deletions auth/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,24 @@ func (auth *Authenticator) CreateSession(ctx context.Context, user User, ttl tim
return session, nil
}

// GetSession returns a session by ID. Return a not found error if the session is not found, or is invalid.
func (auth *Authenticator) GetSession(sessionID string) (*LoginSession, error) {
var session LoginSession
_, err := auth.datastore.Get(auth.DocIDForSession(sessionID), &session)
if err != nil {
if base.IsDocNotFoundError(err) {
err = nil
}
return nil, err
}
user, err := auth.GetUser(session.Username)
if err != nil {
return nil, err
}
if user == nil {
return nil, base.ErrNotFound
}
if session.SessionUUID != user.GetSessionUUID() {
return nil, base.ErrNotFound
}

return &session, nil
}

Expand Down
3 changes: 1 addition & 2 deletions auth/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ func TestDeleteSession(t *testing.T) {
assert.NoError(t, dataStore.Set(auth.DocIDForSession(mockSession.ID), noSessionExpiry, nil, mockSession))
assert.NoError(t, auth.DeleteSession(ctx, mockSession.ID, ""))

// Just to verify the session has been deleted gracefully.
session, err := auth.GetSession(mockSession.ID)
assert.Nil(t, session)
assert.NoError(t, err)
base.RequireDocNotFoundError(t, err)
}

// Coverage for MakeSessionCookie. The MakeSessionCookie should create a cookie
Expand Down
Loading
Loading