@absolutejs/vulnerabilities-postgres 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +147 -147
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -478,7 +478,7 @@ var vulnerabilityAlertDrizzleSchema = {
|
|
|
478
478
|
vulnerabilityAlertIncidents,
|
|
479
479
|
vulnerabilityAlertPolicyVersions
|
|
480
480
|
};
|
|
481
|
-
var queue = async (
|
|
481
|
+
var queue = async (transaction, alert, configuration, kind, occurrence) => {
|
|
482
482
|
const audiences = resolveVulnerabilityAlertAudiences2({
|
|
483
483
|
configuration,
|
|
484
484
|
hasOwner: alert.assetId !== null,
|
|
@@ -487,7 +487,7 @@ var queue = async (transaction2, alert, configuration, kind, occurrence) => {
|
|
|
487
487
|
});
|
|
488
488
|
if (audiences.length === 0)
|
|
489
489
|
return;
|
|
490
|
-
await
|
|
490
|
+
await transaction.insert(vulnerabilityAlertDeliveries).values(audiences.map((audience) => ({
|
|
491
491
|
alert_id: alert.id,
|
|
492
492
|
audience,
|
|
493
493
|
id: crypto.randomUUID(),
|
|
@@ -509,14 +509,14 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
509
509
|
const reason = input.reason.trim();
|
|
510
510
|
if (!reason)
|
|
511
511
|
throw new VulnerabilityAlertValidationError("Policy activation reason is required");
|
|
512
|
-
return db.transaction(async (
|
|
513
|
-
await
|
|
514
|
-
const [latest] = await
|
|
512
|
+
return db.transaction(async (transaction) => {
|
|
513
|
+
await transaction.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${`vulnerability-alert-policy:${input.tenantId}`}))`);
|
|
514
|
+
const [latest] = await transaction.select({
|
|
515
515
|
version: sql`COALESCE(${max(vulnerabilityAlertPolicyVersions.version)}, 0)::integer`
|
|
516
516
|
}).from(vulnerabilityAlertPolicyVersions).where(eq(vulnerabilityAlertPolicyVersions.tenant_id, input.tenantId));
|
|
517
517
|
const version = (latest?.version ?? 0) + 1;
|
|
518
|
-
await
|
|
519
|
-
await
|
|
518
|
+
await transaction.update(vulnerabilityAlertPolicyVersions).set({ status: "superseded" }).where(and(eq(vulnerabilityAlertPolicyVersions.tenant_id, input.tenantId), eq(vulnerabilityAlertPolicyVersions.status, "active")));
|
|
519
|
+
await transaction.insert(vulnerabilityAlertPolicyVersions).values({
|
|
520
520
|
activated_at: new Date(input.activatedAt),
|
|
521
521
|
activated_by: input.activatedBy,
|
|
522
522
|
configuration: encodedJsonb(configuration),
|
|
@@ -555,14 +555,14 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
555
555
|
}) => {
|
|
556
556
|
const at = observedAt ?? new Date().toISOString();
|
|
557
557
|
const configuration = validateVulnerabilityAlertConfiguration2(policy.configuration);
|
|
558
|
-
return db.transaction(async (
|
|
559
|
-
const [existing] = await
|
|
558
|
+
return db.transaction(async (transaction) => {
|
|
559
|
+
const [existing] = await transaction.select({
|
|
560
560
|
occurrenceCount: vulnerabilityAlertIncidents.occurrence_count,
|
|
561
561
|
status: vulnerabilityAlertIncidents.status
|
|
562
562
|
}).from(vulnerabilityAlertIncidents).where(eq(vulnerabilityAlertIncidents.alert_id, alert.id)).for("update").limit(1);
|
|
563
563
|
const reopened = existing?.status === "resolved";
|
|
564
564
|
const nextEscalationAt = new Date(new Date(at).getTime() + configuration.escalationAfterMs[alert.severity]);
|
|
565
|
-
await
|
|
565
|
+
await transaction.insert(vulnerabilityAlertIncidents).values({
|
|
566
566
|
alert_id: alert.id,
|
|
567
567
|
asset_id: alert.assetId,
|
|
568
568
|
body: alert.body,
|
|
@@ -624,33 +624,33 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
624
624
|
target: vulnerabilityAlertIncidents.alert_id
|
|
625
625
|
});
|
|
626
626
|
if (!existing || reopened) {
|
|
627
|
-
await
|
|
627
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
628
628
|
alert_id: alert.id,
|
|
629
629
|
kind: "opened",
|
|
630
630
|
metadata: encodedJsonb({})
|
|
631
631
|
});
|
|
632
|
-
await queue(
|
|
632
|
+
await queue(transaction, alert, configuration, "opened", existing ? existing.occurrenceCount + 1 : 1);
|
|
633
633
|
}
|
|
634
634
|
return !existing ? "opened" : reopened ? "reopened" : "observed";
|
|
635
635
|
});
|
|
636
636
|
};
|
|
637
637
|
const alertIncidents = {
|
|
638
|
-
acknowledge: (input) => db.transaction(async (
|
|
639
|
-
const [present] = await
|
|
638
|
+
acknowledge: (input) => db.transaction(async (transaction) => {
|
|
639
|
+
const [present] = await transaction.select({ status: vulnerabilityAlertIncidents.status }).from(vulnerabilityAlertIncidents).where(eq(vulnerabilityAlertIncidents.alert_id, input.alertId)).for("update").limit(1);
|
|
640
640
|
if (!present)
|
|
641
641
|
throw new VulnerabilityAlertNotFoundError("Vulnerability alert not found");
|
|
642
642
|
if (present.status === "resolved")
|
|
643
643
|
throw new VulnerabilityAlertConflictError("Resolved vulnerability alerts cannot be acknowledged");
|
|
644
644
|
if (present.status === "acknowledged")
|
|
645
645
|
return false;
|
|
646
|
-
await
|
|
646
|
+
await transaction.update(vulnerabilityAlertIncidents).set({
|
|
647
647
|
acknowledged_at: new Date(input.acknowledgedAt),
|
|
648
648
|
acknowledged_by: input.acknowledgedBy,
|
|
649
649
|
next_escalation_at: null,
|
|
650
650
|
status: "acknowledged",
|
|
651
651
|
updated_at: new Date(input.acknowledgedAt)
|
|
652
652
|
}).where(eq(vulnerabilityAlertIncidents.alert_id, input.alertId));
|
|
653
|
-
await
|
|
653
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
654
654
|
actor_id: input.acknowledgedBy,
|
|
655
655
|
alert_id: input.alertId,
|
|
656
656
|
kind: "acknowledged",
|
|
@@ -658,11 +658,11 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
658
658
|
});
|
|
659
659
|
return true;
|
|
660
660
|
}),
|
|
661
|
-
claimDeliveries: (input = {}) => db.transaction(async (
|
|
661
|
+
claimDeliveries: (input = {}) => db.transaction(async (transaction) => {
|
|
662
662
|
const leaseMs = input.leaseMs ?? 300000;
|
|
663
663
|
const queryLimit = boundedLimit2(input.limit ?? 100);
|
|
664
664
|
const due = or(and(inArray(vulnerabilityAlertDeliveries.state, ["pending", "failed"]), lte(vulnerabilityAlertDeliveries.next_attempt_at, databaseNow)), and(eq(vulnerabilityAlertDeliveries.state, "delivering"), lte(vulnerabilityAlertDeliveries.lease_expires_at, databaseNow)));
|
|
665
|
-
const candidates = await
|
|
665
|
+
const candidates = await transaction.select({ id: vulnerabilityAlertDeliveries.id }).from(vulnerabilityAlertDeliveries).innerJoin(vulnerabilityAlertIncidents, eq(vulnerabilityAlertIncidents.alert_id, vulnerabilityAlertDeliveries.alert_id)).where(and(due, input.tenantIds && input.tenantIds.length > 0 ? inArray(vulnerabilityAlertIncidents.tenant_id, [
|
|
666
666
|
...input.tenantIds
|
|
667
667
|
]) : undefined)).orderBy(asc(vulnerabilityAlertDeliveries.created_at)).limit(queryLimit).for("update", {
|
|
668
668
|
of: vulnerabilityAlertDeliveries,
|
|
@@ -671,13 +671,13 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
671
671
|
const ids = candidates.map(({ id }) => id);
|
|
672
672
|
if (ids.length === 0)
|
|
673
673
|
return [];
|
|
674
|
-
await
|
|
674
|
+
await transaction.update(vulnerabilityAlertDeliveries).set({
|
|
675
675
|
attempt_count: sql`${vulnerabilityAlertDeliveries.attempt_count} + 1`,
|
|
676
676
|
lease_expires_at: sql`now() + ${leaseMs} * interval '1 millisecond'`,
|
|
677
677
|
state: "delivering",
|
|
678
678
|
updated_at: databaseNow
|
|
679
679
|
}).where(inArray(vulnerabilityAlertDeliveries.id, ids));
|
|
680
|
-
return
|
|
680
|
+
return transaction.select({
|
|
681
681
|
alert_id: vulnerabilityAlertDeliveries.alert_id,
|
|
682
682
|
asset_id: vulnerabilityAlertIncidents.asset_id,
|
|
683
683
|
attempt_count: vulnerabilityAlertDeliveries.attempt_count,
|
|
@@ -698,8 +698,8 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
698
698
|
updated_at: vulnerabilityAlertDeliveries.updated_at
|
|
699
699
|
}).from(vulnerabilityAlertDeliveries).innerJoin(vulnerabilityAlertIncidents, eq(vulnerabilityAlertIncidents.alert_id, vulnerabilityAlertDeliveries.alert_id)).where(inArray(vulnerabilityAlertDeliveries.id, ids));
|
|
700
700
|
}),
|
|
701
|
-
completeDelivery: (input) => db.transaction(async (
|
|
702
|
-
const updated = await
|
|
701
|
+
completeDelivery: (input) => db.transaction(async (transaction) => {
|
|
702
|
+
const updated = await transaction.update(vulnerabilityAlertDeliveries).set({
|
|
703
703
|
delivered_at: databaseNow,
|
|
704
704
|
last_error: null,
|
|
705
705
|
lease_expires_at: null,
|
|
@@ -708,7 +708,7 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
708
708
|
}).where(and(eq(vulnerabilityAlertDeliveries.id, input.deliveryId), eq(vulnerabilityAlertDeliveries.state, "delivering"))).returning({ id: vulnerabilityAlertDeliveries.id });
|
|
709
709
|
if (updated.length === 0)
|
|
710
710
|
return false;
|
|
711
|
-
await
|
|
711
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
712
712
|
alert_id: input.alertId,
|
|
713
713
|
kind: "delivered",
|
|
714
714
|
metadata: encodedJsonb({
|
|
@@ -720,8 +720,8 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
720
720
|
}),
|
|
721
721
|
deliveries: (requestedLimit) => db.select().from(vulnerabilityAlertDeliveries).orderBy(desc(vulnerabilityAlertDeliveries.created_at)).limit(boundedLimit2(requestedLimit)),
|
|
722
722
|
events: (requestedLimit) => db.select().from(vulnerabilityAlertEvents).orderBy(desc(vulnerabilityAlertEvents.created_at)).limit(boundedLimit2(requestedLimit)),
|
|
723
|
-
failDelivery: (input) => db.transaction(async (
|
|
724
|
-
const updated = await
|
|
723
|
+
failDelivery: (input) => db.transaction(async (transaction) => {
|
|
724
|
+
const updated = await transaction.update(vulnerabilityAlertDeliveries).set({
|
|
725
725
|
last_error: input.error,
|
|
726
726
|
lease_expires_at: null,
|
|
727
727
|
next_attempt_at: new Date(input.retryAt),
|
|
@@ -730,7 +730,7 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
730
730
|
}).where(and(eq(vulnerabilityAlertDeliveries.id, input.deliveryId), eq(vulnerabilityAlertDeliveries.state, "delivering"))).returning({ id: vulnerabilityAlertDeliveries.id });
|
|
731
731
|
if (updated.length === 0)
|
|
732
732
|
return false;
|
|
733
|
-
await
|
|
733
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
734
734
|
alert_id: input.alertId,
|
|
735
735
|
kind: "delivery_failed",
|
|
736
736
|
metadata: encodedJsonb({ error: input.error, kind: input.kind })
|
|
@@ -752,19 +752,19 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
752
752
|
const policy = policies.get(incident.tenantId) ?? fallbackPolicy;
|
|
753
753
|
if (!policy)
|
|
754
754
|
continue;
|
|
755
|
-
const changed = await db.transaction(async (
|
|
756
|
-
const claimed = await
|
|
755
|
+
const changed = await db.transaction(async (transaction) => {
|
|
756
|
+
const claimed = await transaction.update(vulnerabilityAlertIncidents).set({
|
|
757
757
|
next_escalation_at: null,
|
|
758
758
|
updated_at: databaseNow
|
|
759
759
|
}).where(and(eq(vulnerabilityAlertIncidents.alert_id, incident.alertId), eq(vulnerabilityAlertIncidents.status, "open"), lte(vulnerabilityAlertIncidents.next_escalation_at, databaseNow))).returning({ id: vulnerabilityAlertIncidents.alert_id });
|
|
760
760
|
if (claimed.length === 0)
|
|
761
761
|
return false;
|
|
762
|
-
await
|
|
762
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
763
763
|
alert_id: incident.alertId,
|
|
764
764
|
kind: "escalated",
|
|
765
765
|
metadata: encodedJsonb({})
|
|
766
766
|
});
|
|
767
|
-
await queue(
|
|
767
|
+
await queue(transaction, {
|
|
768
768
|
assetId: incident.assetId,
|
|
769
769
|
id: incident.alertId,
|
|
770
770
|
severity: incident.severity
|
|
@@ -801,8 +801,8 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
801
801
|
const policy = policies.get(incident.tenantId) ?? fallbackPolicy;
|
|
802
802
|
if (!policy)
|
|
803
803
|
continue;
|
|
804
|
-
const changed = await db.transaction(async (
|
|
805
|
-
const resolved = await
|
|
804
|
+
const changed = await db.transaction(async (transaction) => {
|
|
805
|
+
const resolved = await transaction.update(vulnerabilityAlertIncidents).set({
|
|
806
806
|
next_escalation_at: null,
|
|
807
807
|
resolved_at: at,
|
|
808
808
|
status: "resolved",
|
|
@@ -813,12 +813,12 @@ var createDrizzleVulnerabilityAlertStores = (db) => {
|
|
|
813
813
|
]))).returning({ id: vulnerabilityAlertIncidents.alert_id });
|
|
814
814
|
if (resolved.length === 0)
|
|
815
815
|
return false;
|
|
816
|
-
await
|
|
816
|
+
await transaction.insert(vulnerabilityAlertEvents).values({
|
|
817
817
|
alert_id: incident.alertId,
|
|
818
818
|
kind: "resolved",
|
|
819
819
|
metadata: encodedJsonb({})
|
|
820
820
|
});
|
|
821
|
-
await queue(
|
|
821
|
+
await queue(transaction, {
|
|
822
822
|
assetId: incident.assetId,
|
|
823
823
|
id: incident.alertId,
|
|
824
824
|
severity: incident.severity
|
|
@@ -1047,8 +1047,8 @@ var createDrizzleVulnerabilityStore = (db) => {
|
|
|
1047
1047
|
},
|
|
1048
1048
|
save: async (snapshot) => {
|
|
1049
1049
|
const feedId = requiredText(snapshot.feed.id, "Feed id");
|
|
1050
|
-
await db.transaction(async (
|
|
1051
|
-
await
|
|
1050
|
+
await db.transaction(async (transaction) => {
|
|
1051
|
+
await transaction.insert(vulnerabilityFeedSnapshots).values({
|
|
1052
1052
|
cursor: encodedJsonb2(snapshot.cursor),
|
|
1053
1053
|
feed_id: feedId,
|
|
1054
1054
|
feed_name: requiredText(snapshot.feed.name, "Feed name"),
|
|
@@ -1068,9 +1068,9 @@ var createDrizzleVulnerabilityStore = (db) => {
|
|
|
1068
1068
|
target: vulnerabilityFeedSnapshots.feed_id
|
|
1069
1069
|
});
|
|
1070
1070
|
const recordIds = snapshot.records.map((record) => requiredText(record.id, "Feed record id"));
|
|
1071
|
-
await
|
|
1071
|
+
await transaction.delete(vulnerabilityFeedRecords).where(and2(eq2(vulnerabilityFeedRecords.feed_id, feedId), recordIds.length === 0 ? undefined : notInArray(vulnerabilityFeedRecords.record_id, recordIds)));
|
|
1072
1072
|
if (snapshot.records.length > 0)
|
|
1073
|
-
await
|
|
1073
|
+
await transaction.insert(vulnerabilityFeedRecords).values(snapshot.records.map((record) => ({
|
|
1074
1074
|
feed_id: feedId,
|
|
1075
1075
|
modified_at: new Date(record.modifiedAt),
|
|
1076
1076
|
record_id: requiredText(record.id, "Feed record id"),
|
|
@@ -1128,12 +1128,12 @@ var createDrizzleVulnerabilityStore = (db) => {
|
|
|
1128
1128
|
}));
|
|
1129
1129
|
}
|
|
1130
1130
|
};
|
|
1131
|
-
const saveFindings = async (
|
|
1132
|
-
if (
|
|
1131
|
+
const saveFindings = async (findings) => {
|
|
1132
|
+
if (findings.length === 0)
|
|
1133
1133
|
return;
|
|
1134
|
-
for (const finding of
|
|
1134
|
+
for (const finding of findings)
|
|
1135
1135
|
valid(ManagedVulnerabilityFindingSchema, finding, `Managed finding ${finding.id}`);
|
|
1136
|
-
await db.insert(vulnerabilityFindings).values(
|
|
1136
|
+
await db.insert(vulnerabilityFindings).values(findings.map((finding) => ({
|
|
1137
1137
|
asset_id: finding.assetId,
|
|
1138
1138
|
component_id: finding.componentId,
|
|
1139
1139
|
finding_id: finding.id,
|
|
@@ -1172,13 +1172,13 @@ var createDrizzleVulnerabilityStore = (db) => {
|
|
|
1172
1172
|
save: async (finding) => saveFindings([finding]),
|
|
1173
1173
|
saveMany: saveFindings
|
|
1174
1174
|
};
|
|
1175
|
-
const saveObservations = async (tenantId,
|
|
1176
|
-
if (
|
|
1175
|
+
const saveObservations = async (tenantId, observations) => {
|
|
1176
|
+
if (observations.length === 0)
|
|
1177
1177
|
return;
|
|
1178
1178
|
const normalizedTenantId = requiredText(tenantId, "Tenant id");
|
|
1179
|
-
for (const observation of
|
|
1179
|
+
for (const observation of observations)
|
|
1180
1180
|
valid(VulnerabilityObservationSchema, observation, `Vulnerability observation ${observation.id}`);
|
|
1181
|
-
await db.insert(vulnerabilityObservations).values(
|
|
1181
|
+
await db.insert(vulnerabilityObservations).values(observations.map((observation) => ({
|
|
1182
1182
|
asset_id: observation.assetId,
|
|
1183
1183
|
component_id: observation.componentId,
|
|
1184
1184
|
observation_id: observation.id,
|
|
@@ -1703,7 +1703,7 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1703
1703
|
const tablePrefix = options.tablePrefix ?? "vulnerability";
|
|
1704
1704
|
const ddl = vulnerabilityPostgresSchemaSql(tablePrefix);
|
|
1705
1705
|
const table = prefixTables(tablePrefix);
|
|
1706
|
-
const
|
|
1706
|
+
const sql = options.sql;
|
|
1707
1707
|
const shouldEnsureSchema = options.ensureSchema ?? true;
|
|
1708
1708
|
const alertStores = createPostgresVulnerabilityAlertStores({
|
|
1709
1709
|
ensureSchema: shouldEnsureSchema,
|
|
@@ -1716,7 +1716,7 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1716
1716
|
return Promise.resolve();
|
|
1717
1717
|
if (schemaPromise)
|
|
1718
1718
|
return schemaPromise;
|
|
1719
|
-
schemaPromise = Promise.resolve(
|
|
1719
|
+
schemaPromise = Promise.resolve(sql.unsafe(ddl)).then(() => {
|
|
1720
1720
|
return;
|
|
1721
1721
|
});
|
|
1722
1722
|
return schemaPromise;
|
|
@@ -1725,7 +1725,7 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1725
1725
|
load: async (feedId) => {
|
|
1726
1726
|
await ensureSchema();
|
|
1727
1727
|
const id = requiredText2(feedId, "Feed id");
|
|
1728
|
-
const rows = await
|
|
1728
|
+
const rows = await sql`
|
|
1729
1729
|
SELECT
|
|
1730
1730
|
snapshot.feed_id,
|
|
1731
1731
|
snapshot.feed_name,
|
|
@@ -1741,10 +1741,10 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1741
1741
|
'value', record.value
|
|
1742
1742
|
) ORDER BY record.record_id
|
|
1743
1743
|
)
|
|
1744
|
-
FROM ${
|
|
1744
|
+
FROM ${sql.unsafe(table.records)} record
|
|
1745
1745
|
WHERE record.feed_id = snapshot.feed_id
|
|
1746
1746
|
), '[]'::jsonb) AS records
|
|
1747
|
-
FROM ${
|
|
1747
|
+
FROM ${sql.unsafe(table.snapshots)} snapshot
|
|
1748
1748
|
WHERE snapshot.feed_id = ${id}
|
|
1749
1749
|
`;
|
|
1750
1750
|
const row = rows[0];
|
|
@@ -1777,9 +1777,9 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1777
1777
|
value: record.value
|
|
1778
1778
|
})));
|
|
1779
1779
|
const cursor = JSON.stringify(snapshot.cursor);
|
|
1780
|
-
await
|
|
1780
|
+
await sql`
|
|
1781
1781
|
WITH saved_snapshot AS (
|
|
1782
|
-
INSERT INTO ${
|
|
1782
|
+
INSERT INTO ${sql.unsafe(table.snapshots)} (
|
|
1783
1783
|
feed_id, feed_name, feed_url, cursor, fetched_at, revision, updated_at
|
|
1784
1784
|
) VALUES (
|
|
1785
1785
|
${requiredText2(snapshot.feed.id, "Feed id")},
|
|
@@ -1803,14 +1803,14 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1803
1803
|
FROM jsonb_to_recordset(${records}::jsonb)
|
|
1804
1804
|
AS item(id text, modified_at text, value jsonb)
|
|
1805
1805
|
), removed AS (
|
|
1806
|
-
DELETE FROM ${
|
|
1806
|
+
DELETE FROM ${sql.unsafe(table.records)} record
|
|
1807
1807
|
WHERE record.feed_id = ${snapshot.feed.id}
|
|
1808
1808
|
AND NOT EXISTS (
|
|
1809
1809
|
SELECT 1 FROM incoming WHERE incoming.id = record.record_id
|
|
1810
1810
|
)
|
|
1811
1811
|
RETURNING record_id
|
|
1812
1812
|
), written AS (
|
|
1813
|
-
INSERT INTO ${
|
|
1813
|
+
INSERT INTO ${sql.unsafe(table.records)} (
|
|
1814
1814
|
feed_id, record_id, modified_at, value
|
|
1815
1815
|
)
|
|
1816
1816
|
SELECT saved_snapshot.feed_id, incoming.id, incoming.modified_at, incoming.value
|
|
@@ -1833,8 +1833,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1833
1833
|
throw new Error(`Unsupported feed sync status: ${run.status}`);
|
|
1834
1834
|
if (!Number.isInteger(run.records) || run.records < 0)
|
|
1835
1835
|
throw new Error("Feed sync records must be a non-negative integer");
|
|
1836
|
-
await
|
|
1837
|
-
INSERT INTO ${
|
|
1836
|
+
await sql`
|
|
1837
|
+
INSERT INTO ${sql.unsafe(table.runs)} (
|
|
1838
1838
|
id, feed_id, started_at, completed_at, status, error, records, revision
|
|
1839
1839
|
) VALUES (
|
|
1840
1840
|
${requiredText2(run.id, "Feed sync run id")},
|
|
@@ -1857,9 +1857,9 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1857
1857
|
await ensureSchema();
|
|
1858
1858
|
const feedId = filter.feedId?.trim() || null;
|
|
1859
1859
|
const status = filter.status ?? null;
|
|
1860
|
-
const rows = await
|
|
1860
|
+
const rows = await sql`
|
|
1861
1861
|
SELECT id, feed_id, started_at, completed_at, status, error, records, revision
|
|
1862
|
-
FROM ${
|
|
1862
|
+
FROM ${sql.unsafe(table.runs)}
|
|
1863
1863
|
WHERE (${feedId}::text IS NULL OR feed_id = ${feedId})
|
|
1864
1864
|
AND (${status}::text IS NULL OR status = ${status})
|
|
1865
1865
|
ORDER BY started_at DESC, id DESC
|
|
@@ -1877,16 +1877,16 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1877
1877
|
}));
|
|
1878
1878
|
}
|
|
1879
1879
|
};
|
|
1880
|
-
const saveFindings = async (
|
|
1880
|
+
const saveFindings = async (findings) => {
|
|
1881
1881
|
await ensureSchema();
|
|
1882
|
-
if (
|
|
1882
|
+
if (findings.length === 0)
|
|
1883
1883
|
return;
|
|
1884
|
-
for (const finding of
|
|
1884
|
+
for (const finding of findings) {
|
|
1885
1885
|
const findingId = finding.id;
|
|
1886
1886
|
if (!Value2.Check(ManagedVulnerabilityFindingSchema2, finding))
|
|
1887
1887
|
throw new Error(`Managed finding ${findingId} is invalid`);
|
|
1888
1888
|
}
|
|
1889
|
-
const payload = JSON.stringify(
|
|
1889
|
+
const payload = JSON.stringify(findings.map((finding) => ({
|
|
1890
1890
|
asset_id: finding.assetId,
|
|
1891
1891
|
component_id: finding.componentId,
|
|
1892
1892
|
finding_id: finding.id,
|
|
@@ -1897,8 +1897,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1897
1897
|
tenant_id: finding.tenantId,
|
|
1898
1898
|
value: finding
|
|
1899
1899
|
})));
|
|
1900
|
-
await
|
|
1901
|
-
INSERT INTO ${
|
|
1900
|
+
await sql`
|
|
1901
|
+
INSERT INTO ${sql.unsafe(table.findings)} (
|
|
1902
1902
|
tenant_id, finding_id, asset_id, component_id, severity, status,
|
|
1903
1903
|
first_seen_at, last_seen_at, value, updated_at
|
|
1904
1904
|
)
|
|
@@ -1916,8 +1916,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1916
1916
|
component_id = EXCLUDED.component_id,
|
|
1917
1917
|
severity = EXCLUDED.severity,
|
|
1918
1918
|
status = EXCLUDED.status,
|
|
1919
|
-
first_seen_at = LEAST(${
|
|
1920
|
-
last_seen_at = GREATEST(${
|
|
1919
|
+
first_seen_at = LEAST(${sql.unsafe(table.findings)}.first_seen_at, EXCLUDED.first_seen_at),
|
|
1920
|
+
last_seen_at = GREATEST(${sql.unsafe(table.findings)}.last_seen_at, EXCLUDED.last_seen_at),
|
|
1921
1921
|
value = EXCLUDED.value,
|
|
1922
1922
|
updated_at = now()
|
|
1923
1923
|
`;
|
|
@@ -1931,8 +1931,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1931
1931
|
const findings = {
|
|
1932
1932
|
get: async (tenantId, findingId) => {
|
|
1933
1933
|
await ensureSchema();
|
|
1934
|
-
const rows = await
|
|
1935
|
-
SELECT value FROM ${
|
|
1934
|
+
const rows = await sql`
|
|
1935
|
+
SELECT value FROM ${sql.unsafe(table.findings)}
|
|
1936
1936
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
1937
1937
|
AND finding_id = ${requiredText2(findingId, "Finding id")}
|
|
1938
1938
|
`;
|
|
@@ -1944,8 +1944,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1944
1944
|
const assetId = filter.assetId?.trim() || null;
|
|
1945
1945
|
const severity = filter.severity ?? null;
|
|
1946
1946
|
const status = filter.status ?? null;
|
|
1947
|
-
const rows = await
|
|
1948
|
-
SELECT value FROM ${
|
|
1947
|
+
const rows = await sql`
|
|
1948
|
+
SELECT value FROM ${sql.unsafe(table.findings)}
|
|
1949
1949
|
WHERE tenant_id = ${tenantId}
|
|
1950
1950
|
AND (${assetId}::text IS NULL OR asset_id = ${assetId})
|
|
1951
1951
|
AND (${severity}::text IS NULL OR severity = ${severity})
|
|
@@ -1964,25 +1964,25 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
1964
1964
|
throw new Error("Stored vulnerability observation is invalid");
|
|
1965
1965
|
return observation;
|
|
1966
1966
|
};
|
|
1967
|
-
const saveObservations = async (tenantId,
|
|
1967
|
+
const saveObservations = async (tenantId, observations) => {
|
|
1968
1968
|
await ensureSchema();
|
|
1969
1969
|
const normalizedTenantId = requiredText2(tenantId, "Tenant id");
|
|
1970
|
-
if (
|
|
1970
|
+
if (observations.length === 0)
|
|
1971
1971
|
return;
|
|
1972
|
-
for (const observation of
|
|
1972
|
+
for (const observation of observations) {
|
|
1973
1973
|
const observationId = observation.id;
|
|
1974
1974
|
if (!Value2.Check(VulnerabilityObservationSchema2, observation))
|
|
1975
1975
|
throw new Error(`Vulnerability observation ${observationId} is invalid`);
|
|
1976
1976
|
}
|
|
1977
|
-
const payload = JSON.stringify(
|
|
1977
|
+
const payload = JSON.stringify(observations.map((observation) => ({
|
|
1978
1978
|
asset_id: observation.assetId,
|
|
1979
1979
|
component_id: observation.componentId,
|
|
1980
1980
|
observation_id: observation.id,
|
|
1981
1981
|
observed_at: observation.observedAt,
|
|
1982
1982
|
value: observation
|
|
1983
1983
|
})));
|
|
1984
|
-
await
|
|
1985
|
-
INSERT INTO ${
|
|
1984
|
+
await sql`
|
|
1985
|
+
INSERT INTO ${sql.unsafe(table.observations)} (
|
|
1986
1986
|
tenant_id, observation_id, asset_id, component_id, observed_at, value,
|
|
1987
1987
|
updated_at
|
|
1988
1988
|
)
|
|
@@ -2004,8 +2004,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2004
2004
|
const observations = {
|
|
2005
2005
|
get: async (tenantId, observationId) => {
|
|
2006
2006
|
await ensureSchema();
|
|
2007
|
-
const rows = await
|
|
2008
|
-
SELECT value FROM ${
|
|
2007
|
+
const rows = await sql`
|
|
2008
|
+
SELECT value FROM ${sql.unsafe(table.observations)}
|
|
2009
2009
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2010
2010
|
AND observation_id = ${requiredText2(observationId, "Observation id")}
|
|
2011
2011
|
`;
|
|
@@ -2016,8 +2016,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2016
2016
|
const tenantId = requiredText2(filter.tenantId, "Tenant id");
|
|
2017
2017
|
const assetId = filter.assetId?.trim() || null;
|
|
2018
2018
|
const componentId = filter.componentId?.trim() || null;
|
|
2019
|
-
const rows = await
|
|
2020
|
-
SELECT value FROM ${
|
|
2019
|
+
const rows = await sql`
|
|
2020
|
+
SELECT value FROM ${sql.unsafe(table.observations)}
|
|
2021
2021
|
WHERE tenant_id = ${tenantId}
|
|
2022
2022
|
AND (${assetId}::text IS NULL OR asset_id = ${assetId})
|
|
2023
2023
|
AND (${componentId}::text IS NULL OR component_id = ${componentId})
|
|
@@ -2052,8 +2052,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2052
2052
|
remediate_by: assessment.remediateBy,
|
|
2053
2053
|
value: assessment
|
|
2054
2054
|
})));
|
|
2055
|
-
await
|
|
2056
|
-
INSERT INTO ${
|
|
2055
|
+
await sql`
|
|
2056
|
+
INSERT INTO ${sql.unsafe(table.riskAssessments)} (
|
|
2057
2057
|
tenant_id, finding_id, priority, assessed_at, remediate_by, value,
|
|
2058
2058
|
updated_at
|
|
2059
2059
|
)
|
|
@@ -2076,8 +2076,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2076
2076
|
const riskAssessments = {
|
|
2077
2077
|
get: async (tenantId, findingId) => {
|
|
2078
2078
|
await ensureSchema();
|
|
2079
|
-
const rows = await
|
|
2080
|
-
SELECT value FROM ${
|
|
2079
|
+
const rows = await sql`
|
|
2080
|
+
SELECT value FROM ${sql.unsafe(table.riskAssessments)}
|
|
2081
2081
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2082
2082
|
AND finding_id = ${requiredText2(findingId, "Finding id")}
|
|
2083
2083
|
`;
|
|
@@ -2087,8 +2087,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2087
2087
|
await ensureSchema();
|
|
2088
2088
|
const tenantId = requiredText2(filter.tenantId, "Tenant id");
|
|
2089
2089
|
const priority = filter.priority ?? null;
|
|
2090
|
-
const rows = await
|
|
2091
|
-
SELECT value FROM ${
|
|
2090
|
+
const rows = await sql`
|
|
2091
|
+
SELECT value FROM ${sql.unsafe(table.riskAssessments)}
|
|
2092
2092
|
WHERE tenant_id = ${tenantId}
|
|
2093
2093
|
AND (${priority}::text IS NULL OR priority = ${priority})
|
|
2094
2094
|
ORDER BY assessed_at DESC, finding_id
|
|
@@ -2108,8 +2108,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2108
2108
|
const remediationPlans = {
|
|
2109
2109
|
get: async (tenantId, planId) => {
|
|
2110
2110
|
await ensureSchema();
|
|
2111
|
-
const rows = await
|
|
2112
|
-
SELECT value FROM ${
|
|
2111
|
+
const rows = await sql`
|
|
2112
|
+
SELECT value FROM ${sql.unsafe(table.remediationPlans)}
|
|
2113
2113
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2114
2114
|
AND plan_id = ${requiredText2(planId, "Remediation plan id")}
|
|
2115
2115
|
`;
|
|
@@ -2119,8 +2119,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2119
2119
|
await ensureSchema();
|
|
2120
2120
|
const tenantId = requiredText2(filter.tenantId, "Tenant id");
|
|
2121
2121
|
const status = filter.status ?? null;
|
|
2122
|
-
const rows = await
|
|
2123
|
-
SELECT value FROM ${
|
|
2122
|
+
const rows = await sql`
|
|
2123
|
+
SELECT value FROM ${sql.unsafe(table.remediationPlans)}
|
|
2124
2124
|
WHERE tenant_id = ${tenantId}
|
|
2125
2125
|
AND (${status}::text IS NULL OR status = ${status})
|
|
2126
2126
|
ORDER BY created_at DESC, plan_id
|
|
@@ -2133,8 +2133,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2133
2133
|
const planId = plan.id;
|
|
2134
2134
|
if (!Value2.Check(RemediationPlanSchema2, plan))
|
|
2135
2135
|
throw new Error(`Remediation plan ${planId} is invalid`);
|
|
2136
|
-
await
|
|
2137
|
-
INSERT INTO ${
|
|
2136
|
+
await sql`
|
|
2137
|
+
INSERT INTO ${sql.unsafe(table.remediationPlans)} (
|
|
2138
2138
|
tenant_id, plan_id, status, created_at, value, updated_at
|
|
2139
2139
|
) VALUES (
|
|
2140
2140
|
${requiredText2(tenantId, "Tenant id")}, ${plan.id}, ${plan.status},
|
|
@@ -2157,8 +2157,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2157
2157
|
const remediationExecutions = {
|
|
2158
2158
|
get: async (tenantId, executionId) => {
|
|
2159
2159
|
await ensureSchema();
|
|
2160
|
-
const rows = await
|
|
2161
|
-
SELECT value FROM ${
|
|
2160
|
+
const rows = await sql`
|
|
2161
|
+
SELECT value FROM ${sql.unsafe(table.remediationExecutions)}
|
|
2162
2162
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2163
2163
|
AND execution_id = ${requiredText2(executionId, "Remediation execution id")}
|
|
2164
2164
|
`;
|
|
@@ -2166,8 +2166,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2166
2166
|
},
|
|
2167
2167
|
list: async (tenantId, planId) => {
|
|
2168
2168
|
await ensureSchema();
|
|
2169
|
-
const rows = await
|
|
2170
|
-
SELECT value FROM ${
|
|
2169
|
+
const rows = await sql`
|
|
2170
|
+
SELECT value FROM ${sql.unsafe(table.remediationExecutions)}
|
|
2171
2171
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2172
2172
|
AND plan_id = ${requiredText2(planId, "Remediation plan id")}
|
|
2173
2173
|
ORDER BY started_at DESC, execution_id
|
|
@@ -2180,8 +2180,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2180
2180
|
const executionId = execution.id;
|
|
2181
2181
|
if (!Value2.Check(RemediationExecutionSchema2, execution))
|
|
2182
2182
|
throw new Error(`Remediation execution ${executionId} is invalid`);
|
|
2183
|
-
await
|
|
2184
|
-
INSERT INTO ${
|
|
2183
|
+
await sql`
|
|
2184
|
+
INSERT INTO ${sql.unsafe(table.remediationExecutions)} (
|
|
2185
2185
|
tenant_id, execution_id, plan_id, status, started_at, completed_at,
|
|
2186
2186
|
value, updated_at
|
|
2187
2187
|
) VALUES (
|
|
@@ -2210,8 +2210,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2210
2210
|
const remediationVerifications = {
|
|
2211
2211
|
get: async (tenantId, verificationId) => {
|
|
2212
2212
|
await ensureSchema();
|
|
2213
|
-
const rows = await
|
|
2214
|
-
SELECT value FROM ${
|
|
2213
|
+
const rows = await sql`
|
|
2214
|
+
SELECT value FROM ${sql.unsafe(table.remediationVerifications)}
|
|
2215
2215
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2216
2216
|
AND verification_id = ${requiredText2(verificationId, "Remediation verification id")}
|
|
2217
2217
|
`;
|
|
@@ -2219,8 +2219,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2219
2219
|
},
|
|
2220
2220
|
list: async (tenantId, executionId) => {
|
|
2221
2221
|
await ensureSchema();
|
|
2222
|
-
const rows = await
|
|
2223
|
-
SELECT value FROM ${
|
|
2222
|
+
const rows = await sql`
|
|
2223
|
+
SELECT value FROM ${sql.unsafe(table.remediationVerifications)}
|
|
2224
2224
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2225
2225
|
AND execution_id = ${requiredText2(executionId, "Remediation execution id")}
|
|
2226
2226
|
ORDER BY observed_at DESC, verification_id
|
|
@@ -2233,8 +2233,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2233
2233
|
const verificationId = verification.id;
|
|
2234
2234
|
if (!Value2.Check(RemediationVerificationSchema2, verification))
|
|
2235
2235
|
throw new Error(`Remediation verification ${verificationId} is invalid`);
|
|
2236
|
-
await
|
|
2237
|
-
INSERT INTO ${
|
|
2236
|
+
await sql`
|
|
2237
|
+
INSERT INTO ${sql.unsafe(table.remediationVerifications)} (
|
|
2238
2238
|
tenant_id, verification_id, execution_id, plan_id, status,
|
|
2239
2239
|
observed_at, value, updated_at
|
|
2240
2240
|
) VALUES (
|
|
@@ -2278,8 +2278,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2278
2278
|
value: decision,
|
|
2279
2279
|
vulnerability_id: decision.vulnerabilityId
|
|
2280
2280
|
})));
|
|
2281
|
-
await
|
|
2282
|
-
INSERT INTO ${
|
|
2281
|
+
await sql`
|
|
2282
|
+
INSERT INTO ${sql.unsafe(table.vexDecisions)} (
|
|
2283
2283
|
tenant_id, decision_id, product_id, vulnerability_id, status,
|
|
2284
2284
|
created_at, expires_at, value, updated_at
|
|
2285
2285
|
)
|
|
@@ -2304,8 +2304,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2304
2304
|
const vexDecisions = {
|
|
2305
2305
|
get: async (tenantId, decisionId) => {
|
|
2306
2306
|
await ensureSchema();
|
|
2307
|
-
const rows = await
|
|
2308
|
-
SELECT value FROM ${
|
|
2307
|
+
const rows = await sql`
|
|
2308
|
+
SELECT value FROM ${sql.unsafe(table.vexDecisions)}
|
|
2309
2309
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2310
2310
|
AND decision_id = ${requiredText2(decisionId, "Decision id")}
|
|
2311
2311
|
`;
|
|
@@ -2316,8 +2316,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2316
2316
|
const tenantId = requiredText2(filter.tenantId, "Tenant id");
|
|
2317
2317
|
const productId = filter.productId?.trim() || null;
|
|
2318
2318
|
const vulnerabilityId = filter.vulnerabilityId?.trim() || null;
|
|
2319
|
-
const rows = await
|
|
2320
|
-
SELECT value FROM ${
|
|
2319
|
+
const rows = await sql`
|
|
2320
|
+
SELECT value FROM ${sql.unsafe(table.vexDecisions)}
|
|
2321
2321
|
WHERE tenant_id = ${tenantId}
|
|
2322
2322
|
AND (${productId}::text IS NULL OR product_id = ${productId})
|
|
2323
2323
|
AND (${vulnerabilityId}::text IS NULL OR vulnerability_id = ${vulnerabilityId})
|
|
@@ -2352,8 +2352,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2352
2352
|
tenant_id: application.tenantId,
|
|
2353
2353
|
value: application
|
|
2354
2354
|
})));
|
|
2355
|
-
await
|
|
2356
|
-
INSERT INTO ${
|
|
2355
|
+
await sql`
|
|
2356
|
+
INSERT INTO ${sql.unsafe(table.vexApplications)} (
|
|
2357
2357
|
tenant_id, finding_id, decision_id, applied_at, ended_at, value,
|
|
2358
2358
|
updated_at
|
|
2359
2359
|
)
|
|
@@ -2376,8 +2376,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2376
2376
|
const vexApplications = {
|
|
2377
2377
|
get: async (tenantId, findingId) => {
|
|
2378
2378
|
await ensureSchema();
|
|
2379
|
-
const rows = await
|
|
2380
|
-
SELECT value FROM ${
|
|
2379
|
+
const rows = await sql`
|
|
2380
|
+
SELECT value FROM ${sql.unsafe(table.vexApplications)}
|
|
2381
2381
|
WHERE tenant_id = ${requiredText2(tenantId, "Tenant id")}
|
|
2382
2382
|
AND finding_id = ${requiredText2(findingId, "Finding id")}
|
|
2383
2383
|
`;
|
|
@@ -2393,8 +2393,8 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2393
2393
|
throw new Error("Feed lease ttlMs must be positive and finite");
|
|
2394
2394
|
const now = request.now ?? new Date;
|
|
2395
2395
|
const expiresAt = new Date(now.getTime() + request.ttlMs);
|
|
2396
|
-
const rows = await
|
|
2397
|
-
INSERT INTO ${
|
|
2396
|
+
const rows = await sql`
|
|
2397
|
+
INSERT INTO ${sql.unsafe(table.leases)} (
|
|
2398
2398
|
feed_id, owner_id, expires_at, updated_at
|
|
2399
2399
|
) VALUES (
|
|
2400
2400
|
${requiredText2(request.feedId, "Feed lease feed id")},
|
|
@@ -2406,16 +2406,16 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2406
2406
|
owner_id = EXCLUDED.owner_id,
|
|
2407
2407
|
expires_at = EXCLUDED.expires_at,
|
|
2408
2408
|
updated_at = EXCLUDED.updated_at
|
|
2409
|
-
WHERE ${
|
|
2410
|
-
OR ${
|
|
2409
|
+
WHERE ${sql.unsafe(table.leases)}.expires_at <= ${now.toISOString()}::timestamptz
|
|
2410
|
+
OR ${sql.unsafe(table.leases)}.owner_id = EXCLUDED.owner_id
|
|
2411
2411
|
RETURNING owner_id
|
|
2412
2412
|
`;
|
|
2413
2413
|
return rows[0]?.owner_id === request.ownerId.trim();
|
|
2414
2414
|
},
|
|
2415
2415
|
release: async (feedId, ownerId) => {
|
|
2416
2416
|
await ensureSchema();
|
|
2417
|
-
const rows = await
|
|
2418
|
-
DELETE FROM ${
|
|
2417
|
+
const rows = await sql`
|
|
2418
|
+
DELETE FROM ${sql.unsafe(table.leases)}
|
|
2419
2419
|
WHERE feed_id = ${requiredText2(feedId, "Feed lease feed id")}
|
|
2420
2420
|
AND owner_id = ${requiredText2(ownerId, "Feed lease owner id")}
|
|
2421
2421
|
RETURNING feed_id
|
|
@@ -2441,31 +2441,31 @@ var createPostgresVulnerabilityStore = (options) => {
|
|
|
2441
2441
|
};
|
|
2442
2442
|
};
|
|
2443
2443
|
export {
|
|
2444
|
-
|
|
2445
|
-
vulnerabilityVexApplications,
|
|
2446
|
-
vulnerabilityRiskAssessments,
|
|
2447
|
-
vulnerabilityRemediationVerifications,
|
|
2448
|
-
vulnerabilityRemediationPlans,
|
|
2449
|
-
vulnerabilityRemediationExecutions,
|
|
2450
|
-
vulnerabilityPostgresSchemaSql,
|
|
2451
|
-
vulnerabilityObservations,
|
|
2452
|
-
vulnerabilityFindings,
|
|
2453
|
-
vulnerabilityFeedSyncRuns,
|
|
2454
|
-
vulnerabilityFeedSnapshots,
|
|
2455
|
-
vulnerabilityFeedRecords,
|
|
2456
|
-
vulnerabilityFeedLeases,
|
|
2457
|
-
vulnerabilityCoreDrizzleSchema,
|
|
2458
|
-
vulnerabilityAlertPostgresSchemaSql,
|
|
2459
|
-
vulnerabilityAlertPolicyVersions,
|
|
2460
|
-
vulnerabilityAlertIncidents,
|
|
2461
|
-
vulnerabilityAlertEvents,
|
|
2462
|
-
vulnerabilityAlertDrizzleSchema,
|
|
2463
|
-
vulnerabilityAlertDeliveries,
|
|
2464
|
-
createPostgresVulnerabilityStore,
|
|
2465
|
-
createPostgresVulnerabilityAlertStores,
|
|
2466
|
-
createDrizzleVulnerabilityStore,
|
|
2467
|
-
createDrizzleVulnerabilityAlertStores,
|
|
2468
|
-
VulnerabilityAlertValidationError,
|
|
2444
|
+
VulnerabilityAlertConflictError,
|
|
2469
2445
|
VulnerabilityAlertNotFoundError,
|
|
2470
|
-
|
|
2446
|
+
VulnerabilityAlertValidationError,
|
|
2447
|
+
createDrizzleVulnerabilityAlertStores,
|
|
2448
|
+
createDrizzleVulnerabilityStore,
|
|
2449
|
+
createPostgresVulnerabilityAlertStores,
|
|
2450
|
+
createPostgresVulnerabilityStore,
|
|
2451
|
+
vulnerabilityAlertDeliveries,
|
|
2452
|
+
vulnerabilityAlertDrizzleSchema,
|
|
2453
|
+
vulnerabilityAlertEvents,
|
|
2454
|
+
vulnerabilityAlertIncidents,
|
|
2455
|
+
vulnerabilityAlertPolicyVersions,
|
|
2456
|
+
vulnerabilityAlertPostgresSchemaSql,
|
|
2457
|
+
vulnerabilityCoreDrizzleSchema,
|
|
2458
|
+
vulnerabilityFeedLeases,
|
|
2459
|
+
vulnerabilityFeedRecords,
|
|
2460
|
+
vulnerabilityFeedSnapshots,
|
|
2461
|
+
vulnerabilityFeedSyncRuns,
|
|
2462
|
+
vulnerabilityFindings,
|
|
2463
|
+
vulnerabilityObservations,
|
|
2464
|
+
vulnerabilityPostgresSchemaSql,
|
|
2465
|
+
vulnerabilityRemediationExecutions,
|
|
2466
|
+
vulnerabilityRemediationPlans,
|
|
2467
|
+
vulnerabilityRemediationVerifications,
|
|
2468
|
+
vulnerabilityRiskAssessments,
|
|
2469
|
+
vulnerabilityVexApplications,
|
|
2470
|
+
vulnerabilityVexDecisions
|
|
2471
2471
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/vulnerabilities-postgres",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Durable Postgres feeds, findings, alert incidents, policy history, delivery queues, remediation evidence, and risk assessments for AbsoluteJS vulnerability management.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSL-1.1",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@absolutejs/vulnerabilities/*"
|
|
32
32
|
],
|
|
33
33
|
"optional": false,
|
|
34
|
-
"range": ">=0.14.0 <0.
|
|
35
|
-
"tested": "0.
|
|
34
|
+
"range": ">=0.14.0 <0.17",
|
|
35
|
+
"tested": "0.16.0"
|
|
36
36
|
},
|
|
37
37
|
"drizzle-orm": {
|
|
38
38
|
"artifactImports": [
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"@sinclair/typebox": "0.34.52"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@absolutejs/vulnerabilities": ">=0.14.0 <0.
|
|
86
|
+
"@absolutejs/vulnerabilities": ">=0.14.0 <0.17",
|
|
87
87
|
"drizzle-orm": ">=1.0.0-rc.4 <2"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@absolutejs/vulnerabilities": "0.
|
|
90
|
+
"@absolutejs/vulnerabilities": "0.16.0",
|
|
91
91
|
"@electric-sql/pglite": "0.3.14",
|
|
92
92
|
"@types/bun": "1.3.14",
|
|
93
93
|
"prettier": "3.8.1",
|