filegrc 0.11.0 → 0.12.0
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/model/index.js +9 -5
- package/model/v10.json +12122 -0
- package/model/v9.json +11647 -0
- package/package.json +1 -1
- package/src/agent.js +3 -0
- package/src/audit-populations.js +88 -0
- package/src/audit-preparation.js +7 -2
- package/src/cli.js +186 -13
- package/src/collection-review-integrity.js +118 -0
- package/src/collection-review.js +71 -7
- package/src/collection-scope.js +8 -0
- package/src/evidence-packet.js +328 -46
- package/src/files.js +364 -6
- package/src/git.js +1064 -149
- package/src/index.js +17 -1
- package/src/model-migration.js +221 -5
- package/src/obligations.js +834 -66
- package/src/policy-library/information-security-policy-v2.md +1 -1
- package/src/policy-library.js +85 -8
- package/src/program-path.js +11 -5
- package/src/program-readiness.js +84 -6
- package/src/reconciliation.js +332 -81
- package/src/reporting-route-integrity.js +542 -0
- package/src/reporting-route-sets.js +745 -0
- package/src/server.js +160 -47
- package/src/state.js +30 -8
- package/src/time.js +55 -0
- package/src/validate.js +978 -4
- package/src/web.js +491 -49
- package/src/workflow-history-integrity.js +872 -0
- package/src/workflow.js +36 -10
package/src/time.js
CHANGED
|
@@ -47,6 +47,61 @@ export function currentCalendarDate(timeZone, now = new Date()) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export function localDateTimeValue(value, timeZone) {
|
|
51
|
+
const instant = new Date(value);
|
|
52
|
+
if (Number.isNaN(instant.getTime())) return "";
|
|
53
|
+
const parts = dateTimeParts(instant, timeZone);
|
|
54
|
+
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function timestampFromLocalDateTime(value, timeZone) {
|
|
58
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?$/.exec(value || "");
|
|
59
|
+
if (!match) throw new Error("A local date and time is required.");
|
|
60
|
+
const desired = match.slice(1).map((part, index) => Number(part ?? (index === 5 ? "0" : part)));
|
|
61
|
+
const desiredUtc = Date.UTC(desired[0], desired[1] - 1, desired[2], desired[3], desired[4], desired[5] || 0);
|
|
62
|
+
let instant = new Date(desiredUtc);
|
|
63
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
64
|
+
const parts = dateTimeParts(instant, timeZone);
|
|
65
|
+
const representedUtc = Date.UTC(
|
|
66
|
+
Number(parts.year),
|
|
67
|
+
Number(parts.month) - 1,
|
|
68
|
+
Number(parts.day),
|
|
69
|
+
Number(parts.hour),
|
|
70
|
+
Number(parts.minute),
|
|
71
|
+
Number(parts.second)
|
|
72
|
+
);
|
|
73
|
+
instant = new Date(instant.getTime() + desiredUtc - representedUtc);
|
|
74
|
+
}
|
|
75
|
+
const roundTrip = localDateTimeValue(instant, timeZone);
|
|
76
|
+
const normalized = `${match[1]}-${match[2]}-${match[3]}T${match[4]}:${match[5]}:${match[6] || "00"}`;
|
|
77
|
+
if (roundTrip !== normalized) throw new Error(`The local time ${normalized} does not exist in ${timeZone}.`);
|
|
78
|
+
const matchingInstants = [];
|
|
79
|
+
for (let offsetMinutes = -240; offsetMinutes <= 240; offsetMinutes += 1) {
|
|
80
|
+
const candidate = new Date(instant.getTime() + offsetMinutes * 60_000);
|
|
81
|
+
if (localDateTimeValue(candidate, timeZone) === normalized) matchingInstants.push(candidate.getTime());
|
|
82
|
+
}
|
|
83
|
+
if (new Set(matchingInstants).size > 1) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`The local time ${normalized} occurs more than once in ${timeZone}. Use an RFC 3339 timestamp with an explicit UTC offset.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return instant.toISOString().replace(".000Z", "Z");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function dateTimeParts(instant, timeZone) {
|
|
92
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
93
|
+
timeZone,
|
|
94
|
+
year: "numeric",
|
|
95
|
+
month: "2-digit",
|
|
96
|
+
day: "2-digit",
|
|
97
|
+
hour: "2-digit",
|
|
98
|
+
minute: "2-digit",
|
|
99
|
+
second: "2-digit",
|
|
100
|
+
hourCycle: "h23"
|
|
101
|
+
}).formatToParts(instant);
|
|
102
|
+
return Object.fromEntries(parts.map(({ type, value }) => [type, value]));
|
|
103
|
+
}
|
|
104
|
+
|
|
50
105
|
export function isRfc3339Timestamp(value) {
|
|
51
106
|
const match = /^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):([0-5]\d):([0-5]\d)(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.exec(value || "");
|
|
52
107
|
if (!match) return false;
|