Skip to content

Commit 7ee541b

Browse files
committed
Merge branch 'main' of github.com:coder/coder into dk/notification-prefs/db-audit
2 parents c4b8b31 + ae40f8a commit 7ee541b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+779
-650
lines changed

.github/actions/setup-node/action.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ runs:
1313
- name: Install pnpm
1414
uses: pnpm/action-setup@v3
1515
with:
16-
version: 9
16+
version: 9.6
1717
- name: Setup Node
18-
uses: actions/setup-node@v4.0.1
18+
uses: actions/setup-node@v4.0.3
1919
with:
20-
node-version: 18.19.0
20+
node-version: 20.16.0
2121
# See https://github.com/actions/setup-node#caching-global-packages-data
2222
cache: "pnpm"
2323
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml

.github/workflows/ci.yaml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ jobs:
709709
- test-e2e
710710
- offlinedocs
711711
- sqlc-vet
712-
- dependency-license-review
713712
# Allow this job to run even if the needed jobs fail, are skipped or
714713
# cancelled.
715714
if: always()
@@ -726,7 +725,6 @@ jobs:
726725
echo "- test-js: ${{ needs.test-js.result }}"
727726
echo "- test-e2e: ${{ needs.test-e2e.result }}"
728727
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
729-
echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
730728
echo
731729
732730
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -968,43 +966,3 @@ jobs:
968966
- name: Setup and run sqlc vet
969967
run: |
970968
make sqlc-vet
971-
972-
# dependency-license-review checks that no license-incompatible dependencies have been introduced.
973-
# This action is not intended to do a vulnerability check since that is handled by a separate action.
974-
dependency-license-review:
975-
runs-on: ubuntu-latest
976-
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
977-
steps:
978-
- name: "Checkout Repository"
979-
uses: actions/checkout@v4
980-
- name: "Dependency Review"
981-
id: review
982-
uses: actions/dependency-review-action@v4.3.2
983-
with:
984-
allow-licenses: Apache-2.0, 0BSD, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
985-
allow-dependencies-licenses: "pkg:golang/github.com/coder/wgtunnel@0.1.13-0.20240522110300-ade90dfb2da0, pkg:npm/pako@1.0.11, pkg:npm/caniuse-lite@1.0.30001639, pkg:githubactions/alwaysmeticulous/report-diffs-action/cloud-compute"
986-
license-check: true
987-
vulnerability-check: false
988-
- name: "Report"
989-
# make sure this step runs even if the previous failed
990-
if: always()
991-
shell: bash
992-
env:
993-
VULNERABLE_CHANGES: ${{ steps.review.outputs.invalid-license-changes }}
994-
run: |
995-
fields=( "unlicensed" "unresolved" "forbidden" )
996-
997-
# This is unfortunate that we have to do this but the action does not support failing on
998-
# an unknown license. The unknown dependency could easily have a GPL license which
999-
# would be problematic for us.
1000-
# Track https://github.com/actions/dependency-review-action/issues/672 for when
1001-
# we can remove this brittle workaround.
1002-
for field in "${fields[@]}"; do
1003-
# Use jq to check if the array is not empty
1004-
if [[ $(echo "$VULNERABLE_CHANGES" | jq ".${field} | length") -ne 0 ]]; then
1005-
echo "Invalid or unknown licenses detected, contact @sreya to ensure your added dependency falls under one of our allowed licenses."
1006-
echo "$VULNERABLE_CHANGES" | jq
1007-
exit 1
1008-
fi
1009-
done
1010-
echo "No incompatible licenses detected"

cli/organizationroles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (r *RootCmd) editOrganizationRole(orgContext *OrganizationContext) *serpent
203203
// Do not actually post
204204
updated = customRole
205205
} else {
206-
updated, err = client.PatchOrganizationRole(ctx, org.ID, customRole)
206+
updated, err = client.PatchOrganizationRole(ctx, customRole)
207207
if err != nil {
208208
return xerrors.Errorf("patch role: %w", err)
209209
}

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbauthz/dbauthz.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,23 @@ func (q *querier) UpdateUserDeletedByID(ctx context.Context, id uuid.UUID) error
32893289
return deleteQ(q.log, q.auth, q.db.GetUserByID, q.db.UpdateUserDeletedByID)(ctx, id)
32903290
}
32913291

3292+
func (q *querier) UpdateUserGithubComUserID(ctx context.Context, arg database.UpdateUserGithubComUserIDParams) error {
3293+
user, err := q.db.GetUserByID(ctx, arg.ID)
3294+
if err != nil {
3295+
return err
3296+
}
3297+
3298+
err = q.authorizeContext(ctx, policy.ActionUpdatePersonal, user)
3299+
if err != nil {
3300+
// System user can also update
3301+
err = q.authorizeContext(ctx, policy.ActionUpdate, user)
3302+
if err != nil {
3303+
return err
3304+
}
3305+
}
3306+
return q.db.UpdateUserGithubComUserID(ctx, arg)
3307+
}
3308+
32923309
func (q *querier) UpdateUserHashedPassword(ctx context.Context, arg database.UpdateUserHashedPasswordParams) error {
32933310
user, err := q.db.GetUserByID(ctx, arg.ID)
32943311
if err != nil {

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,12 @@ func (s *MethodTestSuite) TestUser() {
11061106
u := dbgen.User(s.T(), db, database.User{})
11071107
check.Args(u.ID).Asserts(u, policy.ActionDelete).Returns()
11081108
}))
1109+
s.Run("UpdateUserGithubComUserID", s.Subtest(func(db database.Store, check *expects) {
1110+
u := dbgen.User(s.T(), db, database.User{})
1111+
check.Args(database.UpdateUserGithubComUserIDParams{
1112+
ID: u.ID,
1113+
}).Asserts(u, policy.ActionUpdatePersonal)
1114+
}))
11091115
s.Run("UpdateUserHashedPassword", s.Subtest(func(db database.Store, check *expects) {
11101116
u := dbgen.User(s.T(), db, database.User{})
11111117
check.Args(database.UpdateUserHashedPasswordParams{

coderd/database/dbmem/dbmem.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8015,6 +8015,26 @@ func (q *FakeQuerier) UpdateUserDeletedByID(_ context.Context, id uuid.UUID) err
80158015
return sql.ErrNoRows
80168016
}
80178017

8018+
func (q *FakeQuerier) UpdateUserGithubComUserID(_ context.Context, arg database.UpdateUserGithubComUserIDParams) error {
8019+
err := validateDatabaseType(arg)
8020+
if err != nil {
8021+
return err
8022+
}
8023+
8024+
q.mutex.Lock()
8025+
defer q.mutex.Unlock()
8026+
8027+
for i, user := range q.users {
8028+
if user.ID != arg.ID {
8029+
continue
8030+
}
8031+
user.GithubComUserID = arg.GithubComUserID
8032+
q.users[i] = user
8033+
return nil
8034+
}
8035+
return sql.ErrNoRows
8036+
}
8037+
80188038
func (q *FakeQuerier) UpdateUserHashedPassword(_ context.Context, arg database.UpdateUserHashedPasswordParams) error {
80198039
if err := validateDatabaseType(arg); err != nil {
80208040
return err

coderd/database/dbmetrics/dbmetrics.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmock/dbmock.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE users DROP COLUMN github_com_user_id;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE users ADD COLUMN github_com_user_id BIGINT;
2+
3+
COMMENT ON COLUMN users.github_com_user_id IS 'The GitHub.com numerical user ID. At time of implementation, this is used to check if the user has starred the Coder repository.';

coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams,
361361
&i.QuietHoursSchedule,
362362
&i.ThemePreference,
363363
&i.Name,
364+
&i.GithubComUserID,
364365
&i.Count,
365366
); err != nil {
366367
return nil, err

coderd/database/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)