Skip to content

Modular logistics and supply chain operating system (LSOS)

ci: stop seeding a public inspection link

Ronald A. Richardson008598f3011a
diff --git a/.github/actions/postman-contract/action.yml b/.github/actions/postman-contract/action.yml
index 7c74999f..b5fc74e9 100644
--- a/.github/actions/postman-contract/action.yml
+++ b/.github/actions/postman-contract/action.yml
@@ -153,18 +153,6 @@ runs:
-e "CI_STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY}" \
-e "CI_STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}" \
application php artisan tinker --execute="eval(base64_decode('${CODE}'));" 2>&1 || true)"
- # The inspection link token is the whole credential for the public inspection
- # routes, and the line below prints every SEEDED_ value to the job log. A mask
- # only hides what is written after it, so this one is registered first.
- INSPECTION_LINK_TOKEN="$(printf '%s\n' "$OUT" | grep -oE 'SEEDED_INSPECTION_LINK_TOKEN=[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"
- if [[ -n "$INSPECTION_LINK_TOKEN" ]]; then
- echo "::add-mask::$INSPECTION_LINK_TOKEN"
- fi
- # The link's PIN is the second half of that credential, so it is masked first too.
- INSPECTION_LINK_PIN="$(printf '%s\n' "$OUT" | grep -oE 'SEEDED_INSPECTION_LINK_PIN=[0-9]+' | tail -1 | cut -d= -f2 || true)"
- if [[ -n "$INSPECTION_LINK_PIN" ]]; then
- echo "::add-mask::$INSPECTION_LINK_PIN"
- fi
# Always surface what the seed produced, not only when a step later fails.
#
# The mint runs one PHP snippet inside a single try, so the FIRST fixture that
@@ -188,7 +176,6 @@ runs:
NETWORK_KEY="$(printf '%s\n' "$OUT" | grep -oE 'MINTED_NETWORK_KEY=network_[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"
SECONDARY_ORG_ID="$(printf '%s\n' "$OUT" | grep -oE 'SEEDED_SECONDARY_ORGANIZATION_ID=company_[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"
MULTI_ORG_DRIVER_ID="$(printf '%s\n' "$OUT" | grep -oE 'SEEDED_DRIVER_ID=driver_[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"
- INSPECTION_LINK_FORM_ID="$(printf '%s\n' "$OUT" | grep -oE 'SEEDED_INSPECTION_LINK_FORM_ID=[A-Za-z0-9_]+' | tail -1 | cut -d= -f2 || true)"
if [[ -z "$KEY" ]]; then
echo "::error::Could not mint an API key from the running stack. Tinker output:"
printf '%s\n' "$OUT"
@@ -263,17 +250,6 @@ runs:
if [[ -n "$MULTI_ORG_DRIVER_ID" ]]; then
echo "multi_org_driver_id=$MULTI_ORG_DRIVER_ID" >> "$GITHUB_OUTPUT"
fi
- # The public inspection requests authenticate with a link token alone, and a link
- # can only be minted from the console. Absent only means the FleetOps release on
- # this stack predates inspection links. The token was masked above.
- if [[ -n "$INSPECTION_LINK_TOKEN" && -n "$INSPECTION_LINK_FORM_ID" ]]; then
- echo "inspection_link_token=$INSPECTION_LINK_TOKEN" >> "$GITHUB_OUTPUT"
- # Empty on a stack from before PINs, whose links ask for none.
- echo "inspection_link_pin=$INSPECTION_LINK_PIN" >> "$GITHUB_OUTPUT"
- echo "inspection_link_form_id=$INSPECTION_LINK_FORM_ID" >> "$GITHUB_OUTPUT"
- else
- echo "::warning::No inspection link seeded; the public inspection requests will 403."
- fi
if [[ -n "$PLATFORM_TOKEN" ]]; then
echo "::add-mask::$PLATFORM_TOKEN"
echo "platform_token=$PLATFORM_TOKEN" >> "$GITHUB_OUTPUT"
@@ -369,9 +345,6 @@ runs:
NETWORK_KEY: ${{ steps.key.outputs.network_key }}
SECONDARY_ORG_ID: ${{ steps.key.outputs.secondary_organization_id }}
MULTI_ORG_DRIVER_ID: ${{ steps.key.outputs.multi_org_driver_id }}
- INSPECTION_LINK_TOKEN: ${{ steps.key.outputs.inspection_link_token }}
- INSPECTION_LINK_PIN: ${{ steps.key.outputs.inspection_link_pin }}
- INSPECTION_LINK_FORM_ID: ${{ steps.key.outputs.inspection_link_form_id }}
COLLECTIONS: ${{ inputs.collections }}
BASE_URL: ${{ inputs.base-url }}
NAMESPACE: ${{ inputs.namespace }}
@@ -467,9 +440,6 @@ runs:
' --env-var "network_key=${NETWORK_KEY}" \' \
' --env-var "secondary_organization_id=${SECONDARY_ORG_ID}" \' \
' --env-var "multi_org_driver_id=${MULTI_ORG_DRIVER_ID}" \' \
- ' --env-var "inspection_link_token=${INSPECTION_LINK_TOKEN}" \' \
- ' --env-var "inspection_link_pin=${INSPECTION_LINK_PIN}" \' \
- ' --env-var "inspection_link_form_id=${INSPECTION_LINK_FORM_ID}" \' \
' --env-var "payment_reference=ci-contract-payment-reference" \' \
' --env-var "push_token=ci-contract-push-token" \' \
' "${@:2}"' > "$RUNNER"
@@ -595,18 +565,6 @@ runs:
-e 's/((sk|rk|pk)_(live|test)_)[A-Za-z0-9]+/\1<redacted>/g' \
"$f"
done
- # The inspection link token travels in a query string and a form field, not an
- # Authorization header, so the scrub above misses it. It is alphanumeric, so it
- # is safe to use as a pattern as it stands.
- if [[ -n "${INSPECTION_LINK_TOKEN:-}" ]]; then
- sed -i "s/${INSPECTION_LINK_TOKEN}/<redacted>/g" "$ansi" "$log"
- fi
- # Its PIN travels in an X-Inspection-Pin header, which that scrub does not
- # cover either. Six digits can recur elsewhere in a log; redacting those too
- # costs a little legibility and nothing else.
- if [[ -n "${INSPECTION_LINK_PIN:-}" ]]; then
- sed -i "s/${INSPECTION_LINK_PIN}/<redacted>/g" "$ansi" "$log"
- fi
# Read executed/failed out of the reporter's summary table. Each row is
# "| <label> | <executed> | <failed> |", so match the label plus two numbers
diff --git a/scripts/ci/mint-api-key.php b/scripts/ci/mint-api-key.php
index 21c2577c..91621396 100644
--- a/scripts/ci/mint-api-key.php
+++ b/scripts/ci/mint-api-key.php
@@ -366,80 +366,6 @@ try {
echo 'SEEDED_INSPECTION_FORM_ID=' . $inspectionForm->fresh()->public_id . PHP_EOL;
- /* --------------------------------------------------------
- | Inspection link (public, tokenised form)
- * -------------------------------------------------------- */
-
- // The public inspection requests (Retrieve a Public Inspection Form, Upload a
- // Public Inspection Photo, Submit a Public Inspection) authenticate with nothing
- // but a link token. Links are minted from the console, and a public request is
- // resolved through the token's hash, so the plaintext can only come from here.
- //
- // Multi-use and a day long, so the retrieve, the upload and the submit can all
- // use it in one run. One link per form for the CI user, reused on reruns; the
- // token is rotated every run, like the platform token above, and used_at cleared
- // so a reused link never reads as spent.
- //
- // Guarded on the `token` column rather than the class alone: the column arrived
- // after the table, and a stack between the two would throw on insert — which,
- // inside this single try, would abort every fixture after it.
- if (class_exists(\Fleetbase\FleetOps\Models\InspectionLink::class)
- && \Illuminate\Support\Facades\Schema::hasColumn('inspection_links', 'token')) {
- $inspectionLink = \Fleetbase\FleetOps\Models\InspectionLink::withoutGlobalScopes()
- ->where([
- 'company_uuid' => $company->uuid,
- 'inspection_form_uuid' => $inspectionForm->uuid,
- 'created_by_uuid' => $user->uuid,
- ])
- // withoutGlobalScopes() drops the soft-delete scope too, and the public
- // lookup would never find a trashed link.
- ->whereNull('deleted_at')
- ->first();
-
- if (!$inspectionLink) {
- $inspectionLink = new \Fleetbase\FleetOps\Models\InspectionLink();
- $inspectionLink->company_uuid = $company->uuid;
- $inspectionLink->inspection_form_uuid = $inspectionForm->uuid;
- $inspectionLink->created_by_uuid = $user->uuid;
- }
-
- $inspectionLinkToken = \Fleetbase\FleetOps\Models\InspectionLink::generateToken();
-
- // The seeded driver, so the public read's identity carries a driver and its
- // "no phone number" assertion has something to check. No vehicle: none has
- // been seeded yet at this point in the script.
- $inspectionLink->driver_uuid = isset($driverRecord) ? $driverRecord->uuid : null;
- $inspectionLink->vehicle_uuid = null;
- $inspectionLink->token_hash = \Fleetbase\FleetOps\Models\InspectionLink::hashToken($inspectionLinkToken);
- $inspectionLink->token = $inspectionLinkToken;
- $inspectionLink->status = 'active';
- $inspectionLink->single_use = false;
- $inspectionLink->expires_at = \Illuminate\Support\Carbon::now()->addDay();
- $inspectionLink->used_at = null;
-
- // Links carry a PIN, which the public routes ask for in the X-Inspection-Pin
- // header. A fresh one every run, which also clears any wrong-PIN count and
- // lifts a lock left by an earlier run. Guarded like the token: a stack from
- // before PINs has neither the columns nor setPin(), and its links ask for none.
- $inspectionLinkPin = '';
- if (method_exists($inspectionLink, 'setPin')
- && \Illuminate\Support\Facades\Schema::hasColumn('inspection_links', 'pin_hash')) {
- $inspectionLinkPin = \Fleetbase\FleetOps\Models\InspectionLink::generatePin();
- $inspectionLink->setPin($inspectionLinkPin);
- }
-
- $inspectionLink->save();
-
- echo 'SEEDED_INSPECTION_LINK_TOKEN=' . $inspectionLinkToken . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_PIN=' . $inspectionLinkPin . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_FORM_ID=' . $inspectionForm->fresh()->public_id . PHP_EOL;
- } else {
- echo '::warning::Inspection links unavailable; the public inspection requests will 403.' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_TOKEN=' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_PIN=' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_FORM_ID=' . PHP_EOL;
- }
-
/* --------------------------------------------------------
| Inspection form field groups (custom-field system)
* -------------------------------------------------------- */
@@ -626,9 +552,6 @@ try {
}
} else {
echo 'SEEDED_INSPECTION_FORM_ID=' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_TOKEN=' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_PIN=' . PHP_EOL;
- echo 'SEEDED_INSPECTION_LINK_FORM_ID=' . PHP_EOL;
echo 'SEEDED_INSPECTION_FORM_GROUP_IDS=' . PHP_EOL;
}