Skip to content

Commit 9c35de2

Browse files
authored
Merge branch 'main' into fix/DE-980-email-only-maintainer-link
2 parents 4299076 + 17c0bc9 commit 9c35de2

50 files changed

Lines changed: 2399 additions & 108 deletions

Some content is hidden

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

AGENTS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/.env.dist.composed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ CROWD_PACKAGES_DB_PORT=5432
3535
CROWD_PACKAGES_DB_USERNAME=postgres
3636
CROWD_PACKAGES_DB_PASSWORD=example
3737
CROWD_PACKAGES_DB_DATABASE=packages-db
38+
39+
# security-contacts-worker
40+
SECURITY_CONTACTS_USER_AGENT="lfx-security-contacts-worker"

backend/.env.dist.local

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ ENRICHER_BATCH_SIZE=100
185185
ENRICHER_REPO_UPDATE_INTERVAL_HOURS=24
186186
ENRICHER_IDLE_SLEEP_SEC=60
187187

188+
# security-contacts-worker
189+
SECURITY_CONTACTS_USER_AGENT="lfx-security-contacts-worker"
190+
188191
OSSPCKGS_GCP_PROJECT=local-dev
189192
OSSPCKGS_GCS_BUCKET=local-dev
190193
OSSPCKGS_GCP_CREDENTIALS_B64=e30=

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"script:continue-run": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/continue-run.ts",
2020
"script:trigger-webhook": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/trigger-webhook.ts",
2121
"script:send-weekly-analytics-email": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/send-weekly-analytics-email.ts",
22+
"script:merge-members": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/merge-members.ts",
2223
"script:merge-organizations": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/merge-organizations.ts",
2324
"script:refresh-materialized-views": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/refresh-materialized-views.ts",
2425
"script:unmerge-members": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/unmerge-members.ts",

backend/src/api/public/v1/stewardships/getMyActivity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function getMyActivityHandler(req: Request, res: Response): Promise
6565
description: r.content,
6666
actor: r.actor,
6767
createdAt: r.createdAt,
68-
suggestedAction: SUGGESTED_ACTIONS[r.stewardshipStatus] ?? null,
68+
suggestedAction: SUGGESTED_ACTIONS[r.currentStewardshipStatus] ?? null,
6969
})),
7070
meta: {
7171
total,

backend/src/bin/scripts/merge-members.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import commandLineUsage from 'command-line-usage'
33
import * as fs from 'fs'
44
import path from 'path'
55

6+
import { generateUUIDv1 } from '@crowd/common'
67
import { CommonMemberService } from '@crowd/common_services'
78
import { optionsQx } from '@crowd/data-access-layer'
89
import { MemberField, findMemberById } from '@crowd/data-access-layer/src/members'
@@ -33,6 +34,13 @@ const options = [
3334
description:
3435
'The unique ID of a member that will be merged into the first one. This one will be destroyed. You can provide multiple ids here separated by comma.',
3536
},
37+
{
38+
name: 'userId',
39+
alias: 'u',
40+
typeLabel: '{underline userId}',
41+
type: String,
42+
description: 'User ID of the user performing the merge.',
43+
},
3644
{
3745
name: 'help',
3846
alias: 'h',
@@ -65,6 +73,8 @@ if (parameters.help || !parameters.originalId || !parameters.targetId) {
6573
const originalId = parameters.originalId
6674
const targetIds = parameters.targetId.split(',')
6775

76+
const userId = parameters.userId
77+
6878
const options = await SequelizeRepository.getDefaultIRepositoryOptions()
6979
const qx = SequelizeRepository.getQueryExecutor(options)
7080

@@ -74,6 +84,16 @@ if (parameters.help || !parameters.originalId || !parameters.targetId) {
7484
])
7585

7686
options.currentTenant = { id: originalMember.tenantId }
87+
options.currentUser = { id: userId }
88+
89+
const ctx = {
90+
...options,
91+
requestId: generateUUIDv1(),
92+
userData: {
93+
ip: '127.0.0.1',
94+
userAgent: 'merge-members-script',
95+
},
96+
}
7797

7898
for (const targetId of targetIds) {
7999
const targetMember = await findMemberById(qx, targetId, [
@@ -89,7 +109,7 @@ if (parameters.help || !parameters.originalId || !parameters.targetId) {
89109
log.info(`Merging ${targetId} into ${originalId}...`)
90110
const service = new CommonMemberService(optionsQx(options), options.temporal, log)
91111
try {
92-
await service.merge(originalId, targetId)
112+
await service.merge(originalId, targetId, ctx)
93113
} catch (err) {
94114
log.error(`Error merging members: ${err.message}`)
95115
process.exit(1)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Store the stewardship status as it was at the moment each activity was logged.
2+
-- Existing rows get NULL (no history to reconstruct); queries fall back to s.status for them.
3+
ALTER TABLE stewardship_activity
4+
ADD COLUMN IF NOT EXISTS status_at_time TEXT;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE TABLE IF NOT EXISTS security_contacts (
2+
id BIGSERIAL PRIMARY KEY,
3+
repo_id BIGINT NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
4+
channel TEXT NOT NULL,
5+
value TEXT NOT NULL,
6+
role TEXT NOT NULL,
7+
name TEXT,
8+
score NUMERIC(4,3) NOT NULL,
9+
confidence TEXT NOT NULL,
10+
provenance JSONB NOT NULL DEFAULT '[]',
11+
last_refreshed TIMESTAMPTZ NOT NULL DEFAULT NOW(),
12+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
13+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
14+
);
15+
16+
CREATE UNIQUE INDEX IF NOT EXISTS security_contacts_repo_channel_value_uq
17+
ON security_contacts (repo_id, channel, value);
18+
19+
CREATE INDEX IF NOT EXISTS security_contacts_repo_confidence_idx
20+
ON security_contacts (repo_id, confidence);
21+
22+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS pvr_enabled BOOL;
23+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS security_policy_url TEXT;
24+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS vulnerability_reporting_url TEXT;
25+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS bug_bounty_url TEXT;
26+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS security_txt_url TEXT;
27+
ALTER TABLE repos ADD COLUMN IF NOT EXISTS contacts_last_refreshed TIMESTAMPTZ;

pnpm-lock.yaml

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

scripts/builders/packages.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
DOCKERFILE="./services/docker/Dockerfile.packages"
22
CONTEXT="../"
33
REPO="sjc.ocir.io/axbydjxa5zuh/packages"
4-
SERVICES="github-repos-enricher bq-dataset-ingest npm-worker maven-worker osv-worker dockerhub-sync cargo-worker go-worker nuget-worker"
4+
SERVICES="github-repos-enricher bq-dataset-ingest npm-worker maven-worker osv-worker dockerhub-sync cargo-worker go-worker nuget-worker security-contacts-worker"

0 commit comments

Comments
 (0)