@runeditrun/rer 0.2.83 → 0.2.85
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/README.md +21 -24
- package/cli/README.md +17 -1
- package/cli/authoring.mjs +1 -0
- package/cli/bounded.mjs +1 -1
- package/cli/business/carry.mjs +149 -0
- package/cli/business/command.mjs +6 -1
- package/cli/business/connect.mjs +1 -1
- package/cli/business/local-commands.mjs +2 -0
- package/cli/business/opt-ins.mjs +8 -4
- package/cli/business/questions.mjs +4 -1
- package/cli/business/state.mjs +1 -1
- package/cli/business/supervisor.mjs +7 -1
- package/cli/container-transfer.mjs +2 -2
- package/cli/contract.mjs +7 -7
- package/cli/demo-host.mjs +5 -1
- package/cli/demo-native.mjs +2 -1
- package/cli/demo.mjs +6 -1
- package/cli/deploy-command.mjs +6 -4
- package/cli/deploy.mjs +9 -7
- package/cli/errors.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/human-error.mjs +20 -0
- package/cli/lifecycle.mjs +23 -5
- package/cli/main.mjs +1 -1
- package/cli/managed-data-schema.mjs +114 -0
- package/cli/managed-data-zip.mjs +116 -0
- package/cli/managed-data.mjs +110 -0
- package/cli/managed-server.mjs +25 -14
- package/cli/native-owner-entry.mjs +86 -0
- package/cli/output.mjs +3 -2
- package/cli/parse.mjs +3 -3
- package/cli/portability-empty.mjs +59 -0
- package/cli/portability-migrations.mjs +7 -5
- package/cli/portability-policy.mjs +5 -2
- package/cli/portability-worker.mjs +15 -6
- package/cli/portability.mjs +30 -8
- package/cli/ready-summary.mjs +9 -0
- package/cli/run-transfers.mjs +37 -0
- package/cli/runtime-front-door.mjs +4 -4
- package/cli/server-proxy.mjs +4 -3
- package/cli/server-registry.mjs +13 -8
- package/cli/site.mjs +6 -1
- package/cli/transfers.mjs +17 -4
- package/edition-authoring/base-copies.mjs +125 -30
- package/edition-authoring/copy-checkout.mjs +7 -120
- package/edition-authoring/edition-migrations.mjs +41 -0
- package/edition-authoring/files.mjs +67 -0
- package/edition-authoring/lock.mjs +2 -2
- package/edition-authoring/module-closure.mjs +232 -0
- package/edition-authoring/module-edges.mjs +100 -0
- package/edition-authoring/module-resolution.mjs +66 -0
- package/edition-authoring/module-syntax.mjs +57 -0
- package/edition-authoring/package-target.mjs +92 -0
- package/edition-authoring/runtime-dependencies.mjs +74 -97
- package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
- package/edition-authoring/vendor/babel-parser/README.md +21 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
- package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
- package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
- package/edition-authoring/vendor/yaml/LICENSE +13 -0
- package/edition-authoring/vendor/yaml/README.md +11 -0
- package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
- package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
- package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
- package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
- package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
- package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
- package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
- package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
- package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
- package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
- package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
- package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
- package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
- package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
- package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
- package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
- package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
- package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
- package/edition-authoring/vendor/yaml/errors.mjs +57 -0
- package/edition-authoring/vendor/yaml/index.mjs +17 -0
- package/edition-authoring/vendor/yaml/log.mjs +11 -0
- package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
- package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
- package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
- package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
- package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
- package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
- package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
- package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
- package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
- package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
- package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
- package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
- package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
- package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
- package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
- package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
- package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
- package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
- package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
- package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
- package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
- package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
- package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
- package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
- package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
- package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
- package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
- package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
- package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
- package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
- package/edition-authoring/vendor/yaml/util.mjs +11 -0
- package/edition-authoring/vendor/yaml/visit.mjs +233 -0
- package/edition-authoring/workflow-copies.mjs +125 -0
- package/edition-authoring/workflow-scripts.mjs +112 -0
- package/foundation/runtime/contract-docs.mjs +754 -0
- package/foundation/runtime/run-data.d.mts +1 -0
- package/foundation/runtime/run-data.mjs +2 -0
- package/global/CHANGELOG.md +55 -3
- package/global/README.md +21 -24
- package/global/cli/command.mjs +8 -2
- package/global/cli/install.mjs +4 -5
- package/global/cli/path-link.mjs +3 -2
- package/global/cli/repo-command.mjs +3 -7
- package/global/launch/dev.mjs +12 -2
- package/global/launch/facts.mjs +2 -2
- package/global/launch/render.mjs +16 -9
- package/global/launch/state.mjs +4 -4
- package/global/main.mjs +12 -7
- package/install.sh +17 -6
- package/modules/container/README.md +6 -1
- package/modules/container/adapters/d1-limits.mjs +286 -0
- package/modules/container/adapters/d1-sqlite.mjs +95 -0
- package/modules/container/adapters/d1-workerd-preload.mjs +19 -0
- package/modules/container/adapters/d1-workerd-setup.mjs +26 -0
- package/modules/container/adapters/d1-workerd.mjs +5 -0
- package/modules/container/adapters/sqlite-worker.mjs +5 -3
- package/modules/container/build.mjs +1 -0
- package/modules/container/image-variables.mjs +8 -3
- package/modules/container/transfer.mjs +14 -4
- package/modules/container/worker-engine.mjs +3 -3
- package/modules/demo/declaration.mjs +1 -4
- package/modules/demo/vite.mjs +1 -1
- package/modules/demo-host/build.mjs +1 -0
- package/modules/demo-host/native/prepare.mjs +2 -1
- package/modules/demo-host/native/sql.mjs +7 -2
- package/modules/deploy-kit/README.md +23 -3
- package/modules/deploy-kit/d1-import-diagnostics.mjs +56 -0
- package/modules/deploy-kit/d1-import.mjs +17 -5
- package/modules/deploy-kit/diagnostics.mjs +29 -3
- package/modules/deploy-kit/owner-cli.mjs +20 -7
- package/modules/deploy-kit/provider-transport.mjs +19 -4
- package/modules/deploy-kit/provider.mjs +57 -22
- package/modules/deploy-kit/readiness-window.mjs +1 -1
- package/modules/deploy-kit/site.mjs +8 -3
- package/modules/deploy-kit/templates.mjs +3 -3
- package/modules/deploy-kit/worker.mjs +4 -4
- package/modules/import-kit/src/d1/README.md +23 -4
- package/modules/import-kit/src/d1/atomic-prefix.ts +2 -2
- package/modules/import-kit/src/d1/budget.ts +15 -7
- package/modules/import-kit/src/d1/column-layout.ts +5 -0
- package/modules/import-kit/src/d1/creation.ts +15 -8
- package/modules/import-kit/src/d1/database.ts +3 -3
- package/modules/import-kit/src/d1/erasure-pages.ts +2 -1
- package/modules/import-kit/src/d1/erasure.ts +2 -2
- package/modules/import-kit/src/d1/jobs.ts +10 -6
- package/modules/import-kit/src/d1/plans.ts +14 -8
- package/modules/import-kit/src/d1/retirement.ts +2 -2
- package/modules/import-kit/src/d1/sets.ts +1 -3
- package/modules/import-kit/src/d1/staged-creation.ts +3 -3
- package/modules/import-kit/src/door/limits.ts +1 -1
- package/modules/import-kit/src/door/refusals.ts +1 -1
- package/modules/portability/README.md +112 -4
- package/modules/portability/backfills.mjs +9 -8
- package/modules/portability/bridge.mjs +12 -5
- package/modules/portability/catalogue.mjs +12 -5
- package/modules/portability/files.mjs +4 -3
- package/modules/portability/http.mjs +3 -3
- package/modules/portability/import.mjs +18 -9
- package/modules/portability/index.d.mts +4 -3
- package/modules/portability/index.mjs +1 -1
- package/modules/portability/ledgers.mjs +3 -2
- package/modules/portability/legacy-safety.mjs +11 -2
- package/modules/portability/migration-history.mjs +2 -2
- package/modules/portability/progress.mjs +1 -0
- package/modules/portability/restore-empty.mjs +12 -0
- package/modules/release/github-verify.mjs +11 -2
- package/onboarding/adapter.mjs +35 -6
- package/onboarding/app-fetch.mjs +6 -4
- package/onboarding/development-runtime.mjs +19 -0
- package/onboarding/local/operation.mjs +45 -27
- package/onboarding/loopback-fetch.mjs +16 -0
- package/onboarding/operator-installer.mjs +4 -6
- package/onboarding/process-diagnostics.mjs +6 -2
- package/onboarding/production-runtime.mjs +4 -2
- package/onboarding/readiness.mjs +1 -0
- package/package.json +1 -1
- package/scripts/publish-check/README.md +6 -0
- package/scripts/publish-check/history_scan.py +5 -3
- package/scripts/publish-check/hygiene_config.py +2 -1
- package/scripts/publish-check/public_hygiene.py +1 -1
- package/scripts/publish-check/report.py +9 -3
- package/scripts/publish-check/third-party-notices.json +13 -0
- package/scripts/publish-check/third_party_notices.py +38 -0
- package/scripts/publish-check/tree_scan.py +6 -0
- package/scripts/publish-check.mjs +1 -1
package/onboarding/adapter.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { dependencyEnvironment } from './dependency-environment.mjs';
|
|
|
11
11
|
import { labels } from './adapter-labels.mjs';
|
|
12
12
|
import { chooseOrigin, prepareSettings, readSettings } from './adapter-settings.mjs';
|
|
13
13
|
import {listenerPorts,listenerOwnership,inspectionContext} from './process-diagnostics.mjs';
|
|
14
|
-
import { appFetch } from './app-fetch.mjs';
|
|
14
|
+
import { appFetch, loopbackRequest } from './app-fetch.mjs';
|
|
15
15
|
import { owner, signIn } from './adapter-auth.mjs';
|
|
16
16
|
import { installerDevKey } from './dev-identity.mjs';
|
|
17
17
|
import { assertArchiveFree } from './archive-output.mjs';
|
|
@@ -208,26 +208,55 @@ async function start(context, hooks) {
|
|
|
208
208
|
const { store, onApp, signal } = context;
|
|
209
209
|
await store.step(labels.start);
|
|
210
210
|
const [[command, args = [], options = {}]] = await commandsFor(context, hooks.start);
|
|
211
|
-
const { health = '/health', ready, timeoutMs, softAfterMs, intervalMs, ...spawnOptions } = options;
|
|
211
|
+
const { health = '/health', ready, timeoutMs, softAfterMs, intervalMs, runtimePortHandshake, ...spawnOptions } = options;
|
|
212
212
|
if (hooks.guard) await hooks.guard(context);
|
|
213
213
|
let child;
|
|
214
214
|
try { child = store.spawn(labels.start, command, args, { cwd: context.root, signal, ...spawnOptions }); } catch (error) {
|
|
215
215
|
if (signal?.aborted) throw error;
|
|
216
216
|
throw installationFailure('command_failed', { step: 'start', diagnostic: error });
|
|
217
217
|
}
|
|
218
|
+
let announcement,detectedMismatch;
|
|
219
|
+
const mismatch=port=>({fatal:detectedMismatch=`the application listened on port ${port} but the CLI expected ${expectedPort}`});
|
|
220
|
+
const announced=message=>{if(message?.type==='rer-listening')announcement=message;};
|
|
221
|
+
if(runtimePortHandshake)child.on('message',announced);
|
|
218
222
|
context.app = child;
|
|
219
223
|
await onApp(child);
|
|
220
224
|
const url = new URL(health, context.origin).href;
|
|
221
|
-
|
|
222
|
-
const readinessLabel
|
|
225
|
+
let expectedPort=context.runtimePort??Number(new URL(context.origin).port||80);
|
|
226
|
+
const readinessLabel=runtimePortHandshake?`${labels.start} (waiting for the bound internal listener)`:`${labels.start} (expected internal port ${expectedPort})`;
|
|
223
227
|
const ownedPorts=async()=>{
|
|
224
228
|
try{return await listenerPorts(child.pid);}
|
|
225
229
|
catch(error){throw installationFailure('command_failed',{step:'start',diagnostic:error});}
|
|
226
230
|
};
|
|
227
231
|
try {
|
|
228
|
-
await store.waitForReady(readinessLabel, child,
|
|
232
|
+
await store.waitForReady(readinessLabel, child, async probeSignal => {
|
|
233
|
+
if(runtimePortHandshake){
|
|
234
|
+
if(!announcement)return {ready:false,message:'Waiting for the application listener handshake'};
|
|
235
|
+
const {port,requestedPort}=announcement;
|
|
236
|
+
if(!Number.isInteger(port)||port<1||port>65535)return {fatal:'The application reported an invalid listener port.'};
|
|
237
|
+
if(requestedPort!==0)return mismatch(port);
|
|
238
|
+
if(context.runtimePort!==port){
|
|
239
|
+
const ownership=await listenerOwnership(child.pid,port,'127.0.0.1',inspectionContext({port,signal:probeSignal,budgetMs:3000}));
|
|
240
|
+
if(ownership.status!=='owned')return {fatal:'The application listener handshake did not identify an owned socket.'};
|
|
241
|
+
context.setRuntimePort(port);context.runtimePort=port;expectedPort=port;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const result=await (ready??hooks.health??defaultHealth)(url,probeSignal,context);
|
|
245
|
+
if(result===true||result?.ready===true)return result;
|
|
246
|
+
// Auxiliary runtime listeners are common. Only an owned listener serving the
|
|
247
|
+
// application's healthy response proves a mismatched application port.
|
|
248
|
+
const ports=await listenerPorts(child.pid,inspectionContext({signal:probeSignal,budgetMs:3000}));
|
|
249
|
+
if(!ports.includes(expectedPort))for(const port of ports){
|
|
250
|
+
try{
|
|
251
|
+
const reply=await loopbackRequest({port,path:health,headers:{host:new URL(url).host},signal:probeSignal,timeoutMs:1000});
|
|
252
|
+
if(reply.status===200&&JSON.parse(reply.body.toString()).status==='ok')return mismatch(port);
|
|
253
|
+
}catch(error){if(probeSignal.aborted)throw error;}
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}, { signal, timeoutMs: Math.min(timeoutMs??60000,60000), ...(softAfterMs ? { softAfterMs } : {}), ...(intervalMs ? { intervalMs } : {}) });
|
|
229
257
|
} catch (error) {
|
|
230
258
|
if (signal?.aborted) throw error;
|
|
259
|
+
if(detectedMismatch)throw installationFailure('command_failed',{step:'start',diagnostic:error});
|
|
231
260
|
const ports=await ownedPorts();
|
|
232
261
|
if(ports.length){
|
|
233
262
|
let diagnosis;
|
|
@@ -237,7 +266,7 @@ async function start(context, hooks) {
|
|
|
237
266
|
store.report(message);const prior=approvedFailure(error);error=commandFailure(`${prior?.message??readinessLabel}\n${message}`,prior??{});
|
|
238
267
|
}
|
|
239
268
|
throw installationFailure('command_failed', { step: 'start', diagnostic: error });
|
|
240
|
-
}
|
|
269
|
+
} finally { if(runtimePortHandshake)child.removeListener('message',announced); }
|
|
241
270
|
// Another app can take the loopback port between the port check and the bind;
|
|
242
271
|
// its /health would pass. Claim and sign in only against the process this
|
|
243
272
|
// setup started.
|
package/onboarding/app-fetch.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Requests rer itself makes to a local app's own origin (health, sign-in,
|
|
2
|
-
// dev identity).
|
|
2
|
+
// dev identity). Direct loopback fetches close each connection. A front-door
|
|
3
3
|
// origin (http://NAME.localhost:PORT) is never resolved and never goes through
|
|
4
4
|
// the door: rer connects with node:http to that checkout's own proxy on
|
|
5
5
|
// 127.0.0.1, which keeps the Host header (fetch drops a Host override, and musl
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// whatever answers that name (the door, or a process that took its port) never
|
|
11
11
|
// receives rer's own requests, which can carry the checkout's dev key.
|
|
12
12
|
import http from 'node:http';
|
|
13
|
+
import { loopbackFetch } from './loopback-fetch.mjs';
|
|
13
14
|
import { basename, dirname } from 'node:path';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
15
16
|
// The shared loopback predicate, beside this copy in Base or in a seed's scripts/.
|
|
@@ -32,7 +33,8 @@ export function loopbackRequest({ host = '127.0.0.1', port, path = '/', method =
|
|
|
32
33
|
response.on('end', () => resolve({ status: response.statusCode, statusText: response.statusMessage ?? '', rawHeaders: response.rawHeaders, body: Buffer.concat(chunks) }));
|
|
33
34
|
response.on('error', reject);
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
+
const timer=setTimeout(() => request.destroy(Object.assign(Error(`No answer from ${host}:${port} within ${timeoutMs / 1000} s.`), { code: 'ETIMEDOUT' })),timeoutMs);
|
|
37
|
+
request.once('close',()=>clearTimeout(timer));
|
|
36
38
|
request.on('error', reject);
|
|
37
39
|
request.end(body);
|
|
38
40
|
});
|
|
@@ -53,14 +55,14 @@ function unrouted(url) {
|
|
|
53
55
|
export async function appFetch(input, init = {}) {
|
|
54
56
|
let url = new URL(input instanceof Request ? input.url : String(input));
|
|
55
57
|
if (!routes.has(url.origin) && isLocalhostName(url.hostname)) throw unrouted(url);
|
|
56
|
-
if (!routes.has(url.origin)) return
|
|
58
|
+
if (!routes.has(url.origin)) return loopbackFetch(input, init);
|
|
57
59
|
let method = (init.method ?? 'GET').toUpperCase(), body = await bodyBytes(init.body);
|
|
58
60
|
const sent = Object.fromEntries(new Headers(init.headers ?? {}));
|
|
59
61
|
if (body !== undefined && init.body instanceof URLSearchParams && !sent['content-type']) sent['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
|
|
60
62
|
for (let hops = 0; ; hops++) {
|
|
61
63
|
const route = routes.get(url.origin);
|
|
62
64
|
if (!route && isLocalhostName(url.hostname)) throw unrouted(url);
|
|
63
|
-
if (!route) return
|
|
65
|
+
if (!route) return loopbackFetch(url, { ...init, method, body });
|
|
64
66
|
const reply = await loopbackRequest({ port: route.port, path: url.pathname + url.search, method, headers: { ...sent, ...route.headers, host: url.host, ...(body ? { 'content-length': String(body.length) } : {}) }, body, signal: init.signal });
|
|
65
67
|
const headers = new Headers();
|
|
66
68
|
for (let i = 0; i < reply.rawHeaders.length; i += 2) headers.append(reply.rawHeaders[i], reply.rawHeaders[i + 1]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {createRequire} from 'node:module';
|
|
2
|
+
import {join} from 'node:path';
|
|
3
|
+
import {pathToFileURL} from 'node:url';
|
|
4
|
+
|
|
5
|
+
// Bind first, then announce the actual application listener over the private
|
|
6
|
+
// parent channel. No free-port probe is released before Vite binds.
|
|
7
|
+
const require=createRequire(join(process.cwd(),'package.json'));
|
|
8
|
+
const {createServer}=await import(pathToFileURL(require.resolve('vite')).href);
|
|
9
|
+
const args=process.argv.slice(2),port=Number(args[args.indexOf('--port')+1]);
|
|
10
|
+
const server=await createServer({server:{host:'127.0.0.1',port,strictPort:true}});
|
|
11
|
+
let stopping;
|
|
12
|
+
const stop=()=>stopping??=server.close().finally(()=>{if(process.connected)process.disconnect();});
|
|
13
|
+
process.on('SIGINT',()=>void stop());process.on('SIGTERM',()=>void stop());
|
|
14
|
+
try {
|
|
15
|
+
await server.listen();
|
|
16
|
+
const actual=server.httpServer.address().port;
|
|
17
|
+
process.send?.({type:'rer-listening',requestedPort:port,port:actual});
|
|
18
|
+
server.printUrls();
|
|
19
|
+
}catch(error){await stop();throw error;}
|
|
@@ -47,7 +47,12 @@ export async function localOperation(root, inheritedToken) {
|
|
|
47
47
|
try { await file.writeFile(JSON.stringify({ ...self, token })) } finally { await file.close() }
|
|
48
48
|
const acquired = await identity(path)
|
|
49
49
|
return { token, release: async () => {
|
|
50
|
-
|
|
50
|
+
let owner
|
|
51
|
+
try { owner = JSON.parse(await readFile(path, 'utf8')) } catch (error) {
|
|
52
|
+
if (error.code === 'ENOENT') return
|
|
53
|
+
throw error
|
|
54
|
+
}
|
|
55
|
+
if (owner.token === token && await identity(path) === acquired) await unlink(path).catch(missing)
|
|
51
56
|
} }
|
|
52
57
|
}
|
|
53
58
|
|
|
@@ -70,30 +75,36 @@ export async function ownerAlive(owner) {
|
|
|
70
75
|
// just created. Every starter that judged the same stale file competes for one
|
|
71
76
|
// exclusive guard named after that file's identity; only the guard holder may
|
|
72
77
|
// remove it, and only while the path still names that exact file. A new lock
|
|
73
|
-
// has a new identity
|
|
78
|
+
// has a new identity. Keep the judged descriptor open through the takeover:
|
|
79
|
+
// otherwise its deleted inode can be reused by a new lock while a delayed
|
|
80
|
+
// contender still holds the old identity. Filesystem timestamps do not make
|
|
81
|
+
// inode reuse an exclusive ownership primitive.
|
|
74
82
|
async function takeOver(path) {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
let guard
|
|
80
|
-
for (let attempt = 0; !guard; attempt++) {
|
|
81
|
-
try { guard = await open(guardPath, 'wx', 0o600) } catch (error) {
|
|
82
|
-
if (error.code !== 'EEXIST') throw error
|
|
83
|
-
// Another starter is taking over; it, or a faster starter, owns the lock.
|
|
84
|
-
// A guard whose owner was killed is removed once, after its grace.
|
|
85
|
-
if (attempt > 0 || !await removeAbandonedGuard(guardPath, path)) return false
|
|
86
|
-
}
|
|
87
|
-
}
|
|
83
|
+
const stale = await staleIdentity(path)
|
|
84
|
+
if (stale === undefined) return false
|
|
85
|
+
if (stale === null) return true // Already gone: retry the exclusive create.
|
|
86
|
+
const { handle, id: judged } = stale
|
|
88
87
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
const guardPath = `${path}.takeover-${judged}`
|
|
89
|
+
let guard
|
|
90
|
+
for (let attempt = 0; !guard; attempt++) {
|
|
91
|
+
try { guard = await open(guardPath, 'wx', 0o600) } catch (error) {
|
|
92
|
+
if (error.code !== 'EEXIST') throw error
|
|
93
|
+
// Another starter is taking over; it, or a faster starter, owns the lock.
|
|
94
|
+
// A guard whose owner was killed is removed once, after its grace.
|
|
95
|
+
if (attempt > 0 || !await removeAbandonedGuard(guardPath, path)) return false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await guard.writeFile(JSON.stringify(await currentProcess()))
|
|
100
|
+
const current = await identity(path)
|
|
101
|
+
if (current === judged) await unlink(path).catch(missing)
|
|
102
|
+
return true
|
|
103
|
+
} finally {
|
|
104
|
+
await guard.close()
|
|
105
|
+
await unlink(guardPath).catch(missing)
|
|
106
|
+
}
|
|
107
|
+
} finally { await handle.close() }
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
// Returns the identity of a stale lock, null when the lock is already gone, or
|
|
@@ -105,15 +116,22 @@ async function staleIdentity(path) {
|
|
|
105
116
|
if (error.code === 'ENOENT') return null
|
|
106
117
|
throw error
|
|
107
118
|
}
|
|
119
|
+
let retained = false
|
|
108
120
|
try {
|
|
109
121
|
const status = await handle.stat({ bigint: true })
|
|
110
122
|
const id = key(status)
|
|
111
123
|
try {
|
|
112
124
|
const owner = JSON.parse(await handle.readFile('utf8'))
|
|
113
|
-
if (Number.isSafeInteger(owner.pid) && owner.pid > 0)
|
|
125
|
+
if (Number.isSafeInteger(owner.pid) && owner.pid > 0) {
|
|
126
|
+
if (await ownerAlive(owner)) return undefined
|
|
127
|
+
retained = true
|
|
128
|
+
return { handle, id }
|
|
129
|
+
}
|
|
114
130
|
} catch { /* Half-written or unreadable: judged by age below. */ }
|
|
115
|
-
|
|
116
|
-
|
|
131
|
+
if (Date.now() - Number(status.mtimeMs) <= graceMs) return undefined
|
|
132
|
+
retained = true
|
|
133
|
+
return { handle, id }
|
|
134
|
+
} finally { if (!retained) await handle.close() }
|
|
117
135
|
}
|
|
118
136
|
|
|
119
137
|
// A takeover guard left by a killed starter would otherwise block every later
|
|
@@ -162,7 +180,7 @@ async function identity(path) {
|
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
182
|
|
|
165
|
-
//
|
|
183
|
+
// Compare metadata while the judged inode remains pinned by its descriptor.
|
|
166
184
|
const key = (status) => `${status.dev}-${status.ino}-${status.ctimeNs}`
|
|
167
185
|
// A rename changes ctime, so a moved file is matched by its unchanged fields.
|
|
168
186
|
const movedKey = (status) => `${status.dev}-${status.ino}-${status.birthtimeNs}-${status.mtimeNs}`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { basename, dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
const portable = basename(dirname(fileURLToPath(import.meta.url))) === 'base-onboarding';
|
|
5
|
+
const { isLoopbackHost } = await import(new URL(portable ? '../base-cli/modules/operator-auth/loopback.mjs' : '../modules/operator-auth/loopback.mjs', import.meta.url));
|
|
6
|
+
|
|
7
|
+
// Local harness servers may close idle sockets between readiness and a claim.
|
|
8
|
+
// Close each exchange instead of pooling a socket that can already be closed;
|
|
9
|
+
// never retry a request, particularly a POST with effects.
|
|
10
|
+
export function loopbackFetch(input, init = {}) {
|
|
11
|
+
const url = new URL(input instanceof Request ? input.url : String(input));
|
|
12
|
+
if (!['http:', 'https:'].includes(url.protocol) || !isLoopbackHost(url.hostname)) return fetch(input, init);
|
|
13
|
+
const headers = new Headers(init.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
14
|
+
headers.set('connection', 'close');
|
|
15
|
+
return fetch(input, { ...init, headers });
|
|
16
|
+
}
|
|
@@ -5,7 +5,6 @@ import { selectLocalState, LocalStateSafetyError } from './local/state.mjs';
|
|
|
5
5
|
import {operatorPrerequisites} from './operator-prerequisites.mjs';
|
|
6
6
|
import { migrateOperator } from './operator-migrations.mjs';
|
|
7
7
|
import { installOperator } from './operator-install.mjs';
|
|
8
|
-
import { projectViteBinary } from './project-vite.mjs';
|
|
9
8
|
import { join, delimiter } from 'node:path';
|
|
10
9
|
|
|
11
10
|
export function operatorInstaller({ database, features, prepare, prepareData }) {
|
|
@@ -35,11 +34,10 @@ export function operatorInstaller({ database, features, prepare, prepareData })
|
|
|
35
34
|
// No runtime rer starts serves the Local Explorer: it reads and writes the store
|
|
36
35
|
// without the key. trafficProxy also refuses /cdn-cgi/* on the public listener.
|
|
37
36
|
const devBindings = devKey => devKey ? { RER_DEV_KEY: devKey, RER_DEV_IDENTITY: 'on' } : {};
|
|
38
|
-
const
|
|
39
|
-
const developmentEnvironment = () => { const { RER_MODELS_SERVICE, RER_MODELS_KEY, RER_DEMO, RER_DEMO_EXPIRES, RER_STATE_DIR, ...env } = process.env; return env; };
|
|
37
|
+
const developmentEnvironment = () => { const { RER_MODELS_SERVICE, RER_MODELS_KEY, RER_DEMO, RER_DEMO_EXPIRES, RER_STATE_DIR, RER_DEMO_RUN_URL, ...env } = process.env; return env; };
|
|
40
38
|
// A demo's Vite persists to its own folder (the seed's vite.config reads RER_STATE_DIR)
|
|
41
39
|
// and its Worker sees RER_DEMO=1 and the demo's end (modules/demo).
|
|
42
|
-
const demoBindings = demo => demo ? { RER_DEMO: '1', RER_DEMO_EXPIRES: demo.ends, RER_STATE_DIR: demo.state } : {};
|
|
43
|
-
export const developmentTarget = ({ root, origin,
|
|
40
|
+
const demoBindings = demo => demo ? { RER_DEMO: '1', RER_DEMO_EXPIRES: demo.ends, RER_STATE_DIR: demo.state, RER_DEMO_RUN_URL: demo.runUrl } : {};
|
|
41
|
+
export const developmentTarget = ({ root, origin, devKey, modelsLive, demo }) => [process.execPath, [fileURLToPath(new URL('./development-runtime.mjs',import.meta.url)), 'dev', '--host', '127.0.0.1', '--port', '0', '--strictPort'], { runtimePortHandshake: true, stdio: ['ignore','pipe','pipe','ipc'], env: { ...developmentEnvironment(), PATH: [process.env.PATH, join(root, 'node_modules', '.bin')].filter(value => value !== undefined).join(delimiter), RER_DEV_ORIGIN: origin, WRANGLER_SEND_METRICS: 'false', X_LOCAL_EXPLORER: 'false', ...devBindings(devKey), ...(modelsLive ? { RER_MODELS_SERVICE: modelsLive.baseUrl, RER_MODELS_KEY: modelsLive.apiKey } : {}), ...demoBindings(demo) } }];
|
|
44
42
|
|
|
45
|
-
export const previewTarget = ({ origin,
|
|
43
|
+
export const previewTarget = ({ origin, devKey, scheduled }) => [process.execPath, [fileURLToPath(new URL('./production-runtime.mjs', import.meta.url))], { runtimePortHandshake: true, stdio: ['ignore','pipe','pipe','ipc'], env: { ...process.env, RER_DEV_ORIGIN: origin, RER_RUNTIME_HOST: '127.0.0.1', RER_RUNTIME_PORT: '0', WRANGLER_SEND_METRICS: 'false', CLOUDFLARE_INCLUDE_PROCESS_ENV: 'false', X_LOCAL_EXPLORER: 'false', RER_RUNTIME_TRIGGERS: scheduled ? '1' : '0', ...(devKey ? { RER_DEV_KEY: devKey } : {}) } }];
|
|
@@ -158,9 +158,13 @@ async function descendants(pid,context){
|
|
|
158
158
|
const owned=new Set([pid]);for(let changed=true;changed;){changed=false;for(const [child,parent]of rows)if(owned.has(parent)&&!owned.has(child)){owned.add(child);changed=true;}}
|
|
159
159
|
return owned;
|
|
160
160
|
}
|
|
161
|
+
// The process's own listeners first, then its descendants', each in port order:
|
|
162
|
+
// a runtime's own application listener comes before the helper sockets its
|
|
163
|
+
// children open (Miniflare's workerd also answers the application's health).
|
|
161
164
|
export async function listenerPorts(pid,context=inspectionContext()){
|
|
162
|
-
const owned=await descendants(pid,context);
|
|
163
|
-
|
|
165
|
+
const owned=await descendants(pid,context),rows=(await listeners([...owned],context)).filter(row=>owned.has(row.pid));
|
|
166
|
+
const ports=group=>group.flatMap(row=>row.names.map(portOf)).filter(port=>Number.isInteger(port)&&port>0&&port<=65535).sort((a,b)=>a-b);
|
|
167
|
+
return [...new Set([...ports(rows.filter(row=>row.pid===pid)),...ports(rows.filter(row=>row.pid!==pid))])];
|
|
164
168
|
}
|
|
165
169
|
// An exact health address can use positive own-tree evidence. localhost can
|
|
166
170
|
// reach either loopback family, so it also needs a completed inspection with
|
|
@@ -9,7 +9,7 @@ import {watchProductionAssets} from './production-assets.mjs';
|
|
|
9
9
|
// only the pinned Miniflare, which owns one workerd and no bundler or
|
|
10
10
|
// source/config watcher. Built-asset changes refresh its manifest.
|
|
11
11
|
let planner,stopping,runtime,closeAssets;
|
|
12
|
-
const stop=()=>stopping??=(async()=>{planner?.kill('SIGTERM');await closeAssets?.();await runtime?.dispose();})();
|
|
12
|
+
const stop=()=>stopping??=(async()=>{planner?.kill('SIGTERM');await closeAssets?.();await runtime?.dispose();if(process.connected)process.disconnect();})();
|
|
13
13
|
process.on('SIGINT',()=>void stop());process.on('SIGTERM',()=>void stop());
|
|
14
14
|
async function plan(){
|
|
15
15
|
let text='';
|
|
@@ -27,7 +27,9 @@ try{
|
|
|
27
27
|
runtime=new Miniflare({...convertV4MiniflareOptions(options),resourcePersistencePath:resolve(process.cwd(),'.wrangler/state/v3')});
|
|
28
28
|
if(stopping)await runtime.dispose();
|
|
29
29
|
else {
|
|
30
|
-
await runtime.ready;
|
|
30
|
+
const address=await runtime.ready;
|
|
31
|
+
process.send?.({type:'rer-listening',requestedPort:options.port,port:Number(address.port)});
|
|
32
|
+
options.port=Number(address.port);
|
|
31
33
|
if (!stopping) closeAssets=watchProductionAssets(runtime,options,value=>({...convertV4MiniflareOptions(value),resourcePersistencePath:resolve(process.cwd(),'.wrangler/state/v3')}),error=>{process.stderr.write(`Preview asset refresh failed: ${error.message}\n`);process.exitCode=1;void stop();});
|
|
32
34
|
}
|
|
33
35
|
}
|
package/onboarding/readiness.mjs
CHANGED
|
@@ -48,6 +48,7 @@ export async function waitForReadiness(label, child, health, options, capture, r
|
|
|
48
48
|
if(stopped())return await drain();
|
|
49
49
|
if(signal?.aborted)return await fail('cancel');
|
|
50
50
|
if(now()-start>=timeoutMs)return await fail('deadline');
|
|
51
|
+
if(typeof result.value?.fatal==='string')throw failure(result.value.fatal,{reason:'mismatch'});
|
|
51
52
|
if(result.value===true||result.value?.ready===true)return result.value;
|
|
52
53
|
if(typeof result.value==='string')lastHealth=result.value;
|
|
53
54
|
else if(typeof result.value?.message==='string')lastHealth=result.value.message;
|
package/package.json
CHANGED
|
@@ -137,6 +137,12 @@ regenerates the manifest, and its `--check` mode rejects a stale one. An
|
|
|
137
137
|
alphabetic top-level domain label ends before a following digit, so a match
|
|
138
138
|
ends at the DER string's boundary rather than absorbing the next tag byte.
|
|
139
139
|
|
|
140
|
+
`third_party_notices.py` loads Base's listed licence texts and compares the Git
|
|
141
|
+
blob ID of a licence-named file's complete bytes with them, computed from the
|
|
142
|
+
bytes so untracked working files bind the same way. Only `hygiene.email` from
|
|
143
|
+
that file's content becomes a `notice.third-party` entry in `thirdPartyNotices`;
|
|
144
|
+
the path and every other rule are inspected as usual.
|
|
145
|
+
|
|
140
146
|
`controller_metadata.py` recognizes the standalone controller review manifest by
|
|
141
147
|
its exact four-field structure, immutable source revision, descriptor digest,
|
|
142
148
|
relative directory list and path-to-SHA-256 file map, at any JSON path. Only
|
|
@@ -18,6 +18,7 @@ from content_identities import ContentIdentities, candidate as identity_candidat
|
|
|
18
18
|
from checksum_maps import ChecksumMaps
|
|
19
19
|
from credential_assignments import text_rules, Findings
|
|
20
20
|
from assignment import is_assignment
|
|
21
|
+
from third_party_notices import RULE as NOTICE, blob_id
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
def scan(repo, ref='HEAD', public_base=None, env_file=None, project=None, repository=None, *, cache_dir=None, timeout=300, annotation_file=None):
|
|
@@ -37,7 +38,7 @@ def scan(repo, ref='HEAD', public_base=None, env_file=None, project=None, reposi
|
|
|
37
38
|
config = load_config(history.selected(CONFIG))
|
|
38
39
|
reviewed_bytes = history.selected(REVIEWED)
|
|
39
40
|
reviewed = load_reviewed(reviewed_bytes) if reviewed_bytes else {}
|
|
40
|
-
add = Findings(report, reviewed, hashes).add
|
|
41
|
+
add = Findings(report, reviewed, hashes, config['thirdPartyNotices']).add
|
|
41
42
|
try:
|
|
42
43
|
config['pendingDestination'] = destination(history, project, repository)
|
|
43
44
|
except (ValueError, TypeError, UnicodeError):
|
|
@@ -87,7 +88,7 @@ def scan(repo, ref='HEAD', public_base=None, env_file=None, project=None, reposi
|
|
|
87
88
|
rules, provenance, references = inspected[key]
|
|
88
89
|
entry_scope = 'pre-existing' if (scope != 'release-tree' and oid in public_blobs) or public_paths.get(path) == oid else scope
|
|
89
90
|
for rule in rules:
|
|
90
|
-
add(rule, path, commit, oid, entry_scope)
|
|
91
|
+
add(rule, path, commit, blob_id(history.blob(oid)) if rule == NOTICE else oid, entry_scope)
|
|
91
92
|
if references:
|
|
92
93
|
deferred.append((references, path, commit, oid, entry_scope))
|
|
93
94
|
if provenance:
|
|
@@ -109,7 +110,8 @@ def scan(repo, ref='HEAD', public_base=None, env_file=None, project=None, reposi
|
|
|
109
110
|
public_oid = public_paths.get(path)
|
|
110
111
|
scope = 'pre-existing' if public_oid and (public_oid == oid or history.blob(public_oid) == data) else 'working-tree'
|
|
111
112
|
for rule in rules:
|
|
112
|
-
|
|
113
|
+
# A notice names the exact bytes it matched, tracked or not.
|
|
114
|
+
add(rule, path, history.commit, blob_id(data) if rule == NOTICE else oid, scope)
|
|
113
115
|
if references:
|
|
114
116
|
deferred.append((references, path, history.commit, oid, scope))
|
|
115
117
|
if path == 'LICENSE':
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import json
|
|
3
3
|
import re
|
|
4
4
|
from publication_config import intended_public_repositories
|
|
5
|
+
from third_party_notices import third_party_notices
|
|
5
6
|
|
|
6
7
|
# A home segment within a relative path is not an absolute home directory.
|
|
7
8
|
# Match the username itself so a bare home, including one with spaces, counts.
|
|
@@ -34,7 +35,7 @@ def load_config(data=None):
|
|
|
34
35
|
except re.error:
|
|
35
36
|
raise ValueError('invalid internal reference regex') from None
|
|
36
37
|
return {'publicEmails': {e.lower() for e in emails}, 'internalReferencePatterns': compiled,
|
|
37
|
-
'intendedPublicRepositories': intended_public_repositories()}
|
|
38
|
+
'intendedPublicRepositories': intended_public_repositories(), 'thirdPartyNotices': third_party_notices()}
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
def public_email(address, config):
|
|
@@ -18,7 +18,7 @@ SCHEME_CHARACTERS = frozenset('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW
|
|
|
18
18
|
# acquire trailer privileges. Only the address span is omitted from email checks.
|
|
19
19
|
COAUTHOR = re.compile(
|
|
20
20
|
rb'^Co-Authored-By:[ \t]+(?=[^ \t])[^<>\r\n]*[^<>\s][ \t]+<(?P<address>'
|
|
21
|
-
rb'noreply@(?:anthropic|github)\.com|'
|
|
21
|
+
rb'noreply@(?:anthropic|openai|github)\.com|'
|
|
22
22
|
rb'[0-9]+\+[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}@users\.noreply\.github\.com'
|
|
23
23
|
rb')>[ \t]*\r?$', re.I | re.M)
|
|
24
24
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Caller-compatible, value-free publication reports."""
|
|
2
2
|
from policy import safe_path
|
|
3
3
|
from reviewed import FORBIDDEN
|
|
4
|
+
from third_party_notices import RULE as NOTICE
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def new_report(public_base=False):
|
|
@@ -8,20 +9,23 @@ def new_report(public_base=False):
|
|
|
8
9
|
scanner=dict(name='gitleaks', version='8.30.1'),
|
|
9
10
|
history=dict(scope='selected-and-public-base' if public_base else 'all-local-refs-and-selected-commit',
|
|
10
11
|
commits=0, trees=0, blobs=0, commitMessages=0, tagMessages=0),
|
|
11
|
-
findings=[], preExisting=[], warnings=[], fixtures=[], reviewed=[], info=[],
|
|
12
|
+
findings=[], preExisting=[], warnings=[], fixtures=[], reviewed=[], info=[], thirdPartyNotices=[],
|
|
12
13
|
guarantees=dict(historyScanned=False, visualRecognition=False, environmentChecked=False))
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class Findings:
|
|
16
|
-
def __init__(self, report, reviewed, env_hashes):
|
|
17
|
+
def __init__(self, report, reviewed, env_hashes, notices=None):
|
|
17
18
|
self.report, self.reviewed, self.env_hashes = report, reviewed, env_hashes
|
|
19
|
+
self.notices = notices or {}
|
|
18
20
|
self.seen = {}
|
|
19
21
|
|
|
20
22
|
def add(self, rule, path, commit=None, oid=None, scope='newly-public', bucket=None, scanner_rule=None):
|
|
21
23
|
bucket = bucket or ('preExisting' if scope == 'pre-existing' and rule != 'secret.env-match' else 'findings')
|
|
22
24
|
if rule in ('pending-public-destination', 'provenance.declared-source'):
|
|
23
25
|
bucket = 'info'
|
|
24
|
-
if
|
|
26
|
+
if rule == NOTICE:
|
|
27
|
+
bucket = 'thirdPartyNotices'
|
|
28
|
+
if (rule, path, oid) in self.reviewed and bucket not in ('info', 'thirdPartyNotices'):
|
|
25
29
|
if rule in FORBIDDEN:
|
|
26
30
|
self.add('reviewed.forbidden', path, commit, oid, scope)
|
|
27
31
|
else:
|
|
@@ -41,6 +45,8 @@ class Findings:
|
|
|
41
45
|
item['scannerRule'] = scanner_rule
|
|
42
46
|
if bucket == 'info':
|
|
43
47
|
item['severity'] = 'INFO'
|
|
48
|
+
if bucket == 'thirdPartyNotices':
|
|
49
|
+
item.update(package=self.notices[oid]['package'], version=self.notices[oid]['version'])
|
|
44
50
|
self.seen[key] = item
|
|
45
51
|
self.report[bucket].append(item)
|
|
46
52
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"notices": [
|
|
4
|
+
{
|
|
5
|
+
"blob": "e060aaa1fe0f933e699c8feb3fdcc51c2999bf0c",
|
|
6
|
+
"package": "yaml",
|
|
7
|
+
"version": "2.9.1",
|
|
8
|
+
"licence": "ISC",
|
|
9
|
+
"source": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
|
|
10
|
+
"reason": "The LICENSE file of the yaml 2.9.1 npm package, byte for byte (git hash-object of package/LICENSE in that registry tarball), vendored under edition-authoring/vendor/yaml. The ISC licence requires retaining its copyright notice, whose maintainer attribution is third-party public text, not an identity of ours."
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Exact upstream licence texts whose copyright notices are third-party public text, maintained by Base only."""
|
|
2
|
+
import hashlib
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from publication_config import unique_object
|
|
7
|
+
|
|
8
|
+
RULE = 'notice.third-party'
|
|
9
|
+
LICENCE_NAMES = frozenset({'LICENSE', 'LICENCE', 'LICENSE.md', 'LICENSE.txt', 'COPYING'})
|
|
10
|
+
FIELDS = {'blob', 'package', 'version', 'licence', 'source', 'reason'}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def blob_id(data):
|
|
14
|
+
# Git's object identity of these exact bytes, also for files with no tree entry.
|
|
15
|
+
return hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def third_party_notices():
|
|
19
|
+
path = Path(__file__).with_name('third-party-notices.json')
|
|
20
|
+
document = json.loads(path.read_bytes(), object_pairs_hook=unique_object)
|
|
21
|
+
if (not isinstance(document, dict) or set(document) != {'schemaVersion', 'notices'} or
|
|
22
|
+
document['schemaVersion'] != 1 or not isinstance(document['notices'], list)):
|
|
23
|
+
raise ValueError('invalid third-party notices')
|
|
24
|
+
notices = {}
|
|
25
|
+
for entry in document['notices']:
|
|
26
|
+
if (not isinstance(entry, dict) or set(entry) != FIELDS or
|
|
27
|
+
not all(isinstance(entry[k], str) and entry[k].strip() for k in FIELDS) or
|
|
28
|
+
not re.fullmatch(r'[0-9a-f]{40}', entry['blob']) or entry['blob'] in notices):
|
|
29
|
+
raise ValueError('invalid third-party notice')
|
|
30
|
+
notices[entry['blob']] = entry
|
|
31
|
+
return notices
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def notice(path, data, notices):
|
|
35
|
+
"""The listed notice these exact bytes are, only under a licence file name."""
|
|
36
|
+
if path.rsplit('/', 1)[-1] not in LICENCE_NAMES:
|
|
37
|
+
return None
|
|
38
|
+
return notices.get(blob_id(data))
|
|
@@ -10,6 +10,7 @@ from project_identity import tree_identity
|
|
|
10
10
|
from licenses import license_rules
|
|
11
11
|
from git_history import InspectionError
|
|
12
12
|
from trust_bundle import bundles
|
|
13
|
+
from third_party_notices import RULE as NOTICE, notice
|
|
13
14
|
|
|
14
15
|
DEPENDENCY_DIRS = {'.git', 'node_modules'}
|
|
15
16
|
|
|
@@ -40,6 +41,11 @@ def context(history, commit, config):
|
|
|
40
41
|
def text_rules(data, path, config, env_hashes, *, commit_message=False):
|
|
41
42
|
"""Rules, provenance and the repository references whose rules wait for one bulk resolution."""
|
|
42
43
|
rules, provenance, references = inspect(data, path, config, commit_message=commit_message)
|
|
44
|
+
# A listed upstream licence text, byte for byte under a licence file name,
|
|
45
|
+
# keeps its copyright notice: it is reported as a notice, not a finding.
|
|
46
|
+
# The path itself, and every other rule, stays inspected.
|
|
47
|
+
if 'hygiene.email' in rules and notice(path, data, config['thirdPartyNotices']):
|
|
48
|
+
rules = rules - {'hygiene.email'} | {NOTICE}
|
|
43
49
|
path_rules, _, path_references = inspect(path.encode('utf-8', 'surrogateescape'), '@path', config)
|
|
44
50
|
rules.update(path_rules)
|
|
45
51
|
if env_hashes and (environment_match(data, env_hashes) or environment_match(path.encode(), env_hashes)):
|
|
@@ -64,7 +64,7 @@ finally {
|
|
|
64
64
|
if (reason) report = {
|
|
65
65
|
schema: 'rer.publish-check/v3', status: 'INCOMPLETE', complete: false, source: null,
|
|
66
66
|
findings: [{ rule: reason, path: '.', commit: null, scope: 'newly-public' }],
|
|
67
|
-
preExisting: [], warnings: [], fixtures: [], reviewed: [], info: [],
|
|
67
|
+
preExisting: [], warnings: [], fixtures: [], reviewed: [], info: [], thirdPartyNotices: [],
|
|
68
68
|
history: { commits: 0, trees: 0, blobs: 0 },
|
|
69
69
|
guarantees: { historyScanned: false, visualRecognition: false, environmentChecked: false },
|
|
70
70
|
};
|