chore: add send file sandbox evidence package

This commit is contained in:
zhaoyilun
2026-07-11 00:08:56 +08:00
parent fab0f0f5c0
commit 7db022469c
6 changed files with 843 additions and 6 deletions

View File

@@ -0,0 +1,423 @@
param(
[string]$OutputDir = "runs/send-file-sandbox-gate-package",
[switch]$NoZip
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageDir = Join-Path $repo $OutputDir
$zipPath = "$packageDir.zip"
$recorderRelative = Join-Path $OutputDir "recorder"
$recorderDir = Join-Path $packageDir "recorder"
$capabilityDir = Join-Path $packageDir "capability"
$capabilityExe = Join-Path $capabilityDir "isphere-capability-smoke.exe"
if (Test-Path -LiteralPath $packageDir) {
Remove-Item -LiteralPath $packageDir -Recurse -Force
}
if (Test-Path -LiteralPath $zipPath) {
Remove-Item -LiteralPath $zipPath -Force
}
New-Item -ItemType Directory -Force -Path $packageDir | Out-Null
New-Item -ItemType Directory -Force -Path $capabilityDir | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $packageDir "return-evidence") | Out-Null
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\package-live-probe-recorder.ps1") -OutputDir $recorderRelative -NoZip
if ($LASTEXITCODE -ne 0) {
throw "package-live-probe-recorder.ps1 failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path -LiteralPath (Join-Path $recorderDir "ISphereLiveProbeRecorder.exe"))) {
throw "recorder package was not created under $recorderDir"
}
Push-Location $repo
try {
& go build -o $capabilityExe ./cmd/isphere-capability-smoke
if ($LASTEXITCODE -ne 0) {
throw "go build ./cmd/isphere-capability-smoke failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
if (-not (Test-Path -LiteralPath $capabilityExe)) {
throw "capability smoke executable was not created: $capabilityExe"
}
@'
iSphere Send-File Sandbox Gate Package
LOCAL_LOGIN_UNAVAILABLE: the development machine cannot log in to iSphere.
ONLINE_SANDBOX_REQUIRED: run this package only on a machine/network where iSphere/IMPlatformClient can log in.
Goal:
- collect one operator-approved sandbox file-send evidence package;
- keep production file send disabled in the repository;
- return enough evidence to decide whether real file-upload connector work can start later.
What this package does:
- runs the read-only live probe recorder before the manual sandbox file send;
- asks the operator to manually send exactly one sandbox file in the official client;
- runs the same read-only recorder after the manual file send;
- optionally runs the offline capability smoke executable;
- zips the returned evidence folder.
What this package does not do:
- it does not send messages automatically;
- it does not send or upload files automatically;
- it does not click or type;
- it does not hook or inject into the client;
- it does not enable production_file_send_enabled.
Required rule:
- MANUAL_ONE_FILE_SEND_ONLY: send exactly one sandbox file manually.
- DO_NOT_SEND_SECOND_FILE: do not send a second file with the same idempotency_key.
- Put the chosen file under the local ISPHERE_SEND_FILE_ALLOWED_DIR you record in FILE-SEND-INPUTS.json.
- Record sandbox_file_path, file_sha256, file_size_bytes, and idempotency_key in FILE-SEND-INPUTS.json.
- Fill file_upload_or_sent_record after the operator sees upload success, sent-file record, or recipient-visible file evidence.
Return:
- preferred one-file flow: run RUN-FILE-RECORDING-SUITE.bat and follow the pauses.
- or run before/after batch files and then CREATE-FILE-RETURN-ZIP.ps1.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "README.txt") -Encoding UTF8
@'
# R9 Online Sandbox File-Send Gate - Operator Steps
This package is for an online/internal sandbox only.
Markers:
- LOCAL_LOGIN_UNAVAILABLE: do not run this on the local development machine for proof.
- ONLINE_SANDBOX_REQUIRED: run on a machine where iSphere/IMPlatformClient can log in.
- MANUAL_ONE_FILE_SEND_ONLY: send exactly one test file manually.
- DO_NOT_SEND_SECOND_FILE: do not repeat the file send with the same idempotency_key.
## Step 1 - Prepare inputs
1. Copy `FILE-SEND-INPUTS.template.json` to `FILE-SEND-INPUTS.json`.
2. Put the sandbox file in a folder dedicated to the test.
3. Fill `sandbox_target_type`, `sandbox_target_id`, `ISPHERE_SEND_FILE_ALLOWED_DIR`, `sandbox_file_path`, and `idempotency_key`.
4. Compute file hash and size:
```powershell
$file = "<full path to sandbox file>"
(Get-FileHash -Algorithm SHA256 -LiteralPath $file).Hash.ToLowerInvariant()
(Get-Item -LiteralPath $file).Length
```
5. Copy the results into `file_sha256` and `file_size_bytes`.
## Step 2 - Before-file-send recording
1. Open and log in to iSphere/IMPlatformClient normally.
2. Open the sandbox target conversation.
3. Do not send any file yet.
4. Run `run-before-file-recorder.bat`.
Alternative one-file flow: run `RUN-FILE-RECORDING-SUITE.bat`.
## Step 3 - Manual one-file-send action
1. In the official iSphere client, manually send exactly the `sandbox_file_path` file.
2. Send it only to the declared sandbox target.
3. Do not send a second copy.
4. Fill `operator_started_at_local`, `operator_clicked_send_file_at_local`, `operator_observed_file_success_at_local`, `before_recorder_present`, `after_recorder_present`, `file_upload_or_sent_record_present`, `duplicate_second_file_send_attempted`, `manual_file_send_started_at_local`, `manual_file_send_finished_at_local`, `operator_observed_file_success`, `file_upload_or_sent_record`, and `do_not_send_second_file_confirmed` in `FILE-SEND-INPUTS.json`.
## Step 4 - After-file-send recording
Run `run-after-file-recorder.bat`.
## Step 5 - Optional capability smoke
Run:
```powershell
.\capability\isphere-capability-smoke.exe *> .\return-evidence\capability-smoke.txt
```
Expected fields include `tool_count=10`, `send_file_preview_tool_present=true`, and `send_file_production_enabled=false`.
## Step 6 - Return package
Run:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\CREATE-FILE-RETURN-ZIP.ps1
```
Send back the generated zip file. You can also run `03-create-file-return-zip.bat`.
The repository must keep production file send disabled until this evidence is reviewed.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "OPERATOR-FILE-STEPS.md") -Encoding UTF8
@'
{
"gate": "R9 online sandbox file-send evidence gate",
"LOCAL_LOGIN_UNAVAILABLE": true,
"ONLINE_SANDBOX_REQUIRED": true,
"MANUAL_ONE_FILE_SEND_ONLY": true,
"DO_NOT_SEND_SECOND_FILE": true,
"sandbox_target_type": "direct-or-group",
"sandbox_target_id": "<sandbox target id only>",
"ISPHERE_SEND_FILE_ALLOWED_DIR": "<folder that contains only files approved for this test>",
"sandbox_file_path": "<full path to the one sandbox file>",
"file_sha256": "<sha256 hex of sandbox_file_path>",
"file_size_bytes": 0,
"idempotency_key": "<one unique idempotency key>",
"operator_started_at_local": "",
"operator_clicked_send_file_at_local": "",
"operator_observed_file_success_at_local": "",
"before_recorder_present": false,
"after_recorder_present": false,
"file_upload_or_sent_record_present": false,
"duplicate_second_file_send_attempted": false,
"manual_file_send_started_at_local": "",
"manual_file_send_finished_at_local": "",
"operator_observed_file_success": false,
"file_upload_or_sent_record": "",
"do_not_send_second_file_confirmed": false,
"production_file_send_enabled": false,
"notes": ""
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-SEND-INPUTS.template.json") -Encoding UTF8
@'
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "iSphere R9 sandbox file-send inputs",
"type": "object",
"required": [
"sandbox_target_type",
"sandbox_target_id",
"ISPHERE_SEND_FILE_ALLOWED_DIR",
"sandbox_file_path",
"file_sha256",
"file_size_bytes",
"idempotency_key",
"operator_started_at_local",
"operator_clicked_send_file_at_local",
"operator_observed_file_success_at_local",
"before_recorder_present",
"after_recorder_present",
"file_upload_or_sent_record_present",
"duplicate_second_file_send_attempted",
"production_file_send_enabled"
],
"properties": {
"sandbox_target_type": { "type": "string" },
"sandbox_target_id": { "type": "string" },
"ISPHERE_SEND_FILE_ALLOWED_DIR": { "type": "string" },
"sandbox_file_path": { "type": "string" },
"file_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
"file_size_bytes": { "type": "integer", "minimum": 1 },
"idempotency_key": { "type": "string" },
"operator_started_at_local": { "type": "string" },
"operator_clicked_send_file_at_local": { "type": "string" },
"operator_observed_file_success_at_local": { "type": "string" },
"before_recorder_present": { "type": "boolean" },
"after_recorder_present": { "type": "boolean" },
"file_upload_or_sent_record_present": { "type": "boolean" },
"duplicate_second_file_send_attempted": { "type": "boolean" },
"production_file_send_enabled": { "type": "boolean", "const": false }
}
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-SEND-INPUTS.schema.json") -Encoding UTF8
@'
# RETURN-FILE-CHECKLIST
Fill `FILE-SEND-INPUTS.json` and run `CREATE-FILE-RETURN-ZIP.ps1`.
Required fields:
- `operator_started_at_local`
- `operator_clicked_send_file_at_local`
- `operator_observed_file_success_at_local`
- `before_recorder_present=true`
- `after_recorder_present=true`
- `file_upload_or_sent_record_present=true`
- `duplicate_second_file_send_attempted=false`
- `production_file_send_enabled=false`
Return rule:
- One sandbox target only.
- One sandbox_file_path only.
- One file_sha256 only.
- One idempotency_key only.
- MANUAL_ONE_FILE_SEND_ONLY.
- DO_NOT_SEND_SECOND_FILE.
- Do not send a second copy.
- `CREATE-FILE-RETURN-ZIP.ps1` refuses to build a return zip when after-recorder output or required fields are missing.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RETURN-FILE-CHECKLIST.md") -Encoding UTF8
@'
Expected return files for R9:
1. FILE-SEND-INPUTS.json
- sandbox_target_type is filled.
- sandbox_target_id is filled.
- ISPHERE_SEND_FILE_ALLOWED_DIR is filled.
- sandbox_file_path is filled.
- file_sha256 is filled.
- file_size_bytes is greater than 0.
- idempotency_key is filled.
- file_upload_or_sent_record is filled.
- MANUAL_ONE_FILE_SEND_ONLY is true.
- DO_NOT_SEND_SECOND_FILE is true.
- do_not_send_second_file_confirmed is true.
- operator_started_at_local is filled.
- operator_clicked_send_file_at_local is filled.
- operator_observed_file_success_at_local is filled.
- before_recorder_present is true.
- after_recorder_present is true.
- file_upload_or_sent_record_present is true.
- duplicate_second_file_send_attempted is false.
- production_file_send_enabled is false.
2. return-evidence/before/*
3. return-evidence/after/*
4. Optional: return-evidence/capability-smoke.txt with tool_count=10, send_file_preview_tool_present=true, send_file_production_enabled=false.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "EXPECTED-FILE-RETURN-FILES.txt") -Encoding UTF8
@'
param(
[string]$InputsPath = ".\FILE-SEND-INPUTS.json",
[string]$EvidenceDir = ".\return-evidence",
[string]$OutputZip = ""
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function Test-NonEmptyString($Value) {
if ($null -eq $Value) { return $false }
return -not [string]::IsNullOrWhiteSpace([string]$Value)
}
if (-not (Test-Path -LiteralPath $InputsPath)) { throw "missing FILE-SEND-INPUTS.json: copy FILE-SEND-INPUTS.template.json first" }
if (-not (Test-Path -LiteralPath $EvidenceDir)) { throw "missing evidence dir: $EvidenceDir" }
$inputs = Get-Content -LiteralPath $InputsPath -Raw | ConvertFrom-Json
$beforeDir = Join-Path $EvidenceDir "before"
$afterDir = Join-Path $EvidenceDir "after"
$missing = New-Object System.Collections.Generic.List[string]
foreach ($name in @("sandbox_target_type", "sandbox_target_id", "ISPHERE_SEND_FILE_ALLOWED_DIR", "sandbox_file_path", "file_sha256", "idempotency_key", "operator_started_at_local", "operator_clicked_send_file_at_local", "operator_observed_file_success_at_local", "manual_file_send_started_at_local", "manual_file_send_finished_at_local", "file_upload_or_sent_record")) {
$prop = $inputs.PSObject.Properties[$name]
if ($null -eq $prop -or -not (Test-NonEmptyString $prop.Value)) { $missing.Add($name) }
}
if ($null -eq $inputs.file_size_bytes -or [int64]$inputs.file_size_bytes -le 0) { $missing.Add("file_size_bytes") }
if ($inputs.before_recorder_present -ne $true) { $missing.Add("before_recorder_present") }
if ($inputs.after_recorder_present -ne $true) { $missing.Add("after_recorder_present") }
if ($inputs.file_upload_or_sent_record_present -ne $true) { $missing.Add("file_upload_or_sent_record_present") }
if ($inputs.duplicate_second_file_send_attempted -ne $false) { $missing.Add("duplicate_second_file_send_attempted_false") }
if ($inputs.do_not_send_second_file_confirmed -ne $true) { $missing.Add("do_not_send_second_file_confirmed") }
if ($inputs.production_file_send_enabled -ne $false) { $missing.Add("production_file_send_enabled_false") }
if (-not (Test-Path -LiteralPath $beforeDir)) { $missing.Add("return-evidence/before") }
if (-not (Test-Path -LiteralPath $afterDir)) { $missing.Add("return-evidence/after") }
if ($missing.Count -gt 0) { throw ("cannot create return zip; missing: " + ($missing -join ", ")) }
if ([string]::IsNullOrWhiteSpace($OutputZip)) {
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$OutputZip = "isphere-send-file-return-$timestamp.zip"
}
if (Test-Path -LiteralPath $OutputZip) { Remove-Item -LiteralPath $OutputZip -Force }
$items = @($InputsPath, $EvidenceDir) | ForEach-Object { Resolve-Path -LiteralPath $_ }
Compress-Archive -LiteralPath $items.Path -DestinationPath $OutputZip -Force
[ordered]@{
ok = $true
zip = (Resolve-Path -LiteralPath $OutputZip).Path
production_file_send_enabled = $false
duplicate_second_file_send_attempted = $false
} | ConvertTo-Json -Depth 4 -Compress
'@ | Set-Content -LiteralPath (Join-Path $packageDir "CREATE-FILE-RETURN-ZIP.ps1") -Encoding UTF8
@'
@echo off
setlocal
cd /d "%~dp0"
if not exist return-evidence mkdir return-evidence
if not exist return-evidence\before mkdir return-evidence\before
recorder\ISphereLiveProbeRecorder.exe --no-pause > return-evidence\before\recorder-before.txt 2>&1
echo before recorder exit code: %ERRORLEVEL% > return-evidence\before\exit-code.txt
pause
exit /b 0
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-before-file-recorder.bat") -Encoding ASCII
Copy-Item -LiteralPath (Join-Path $packageDir "run-before-file-recorder.bat") -Destination (Join-Path $packageDir "01-run-before-file-recorder.bat") -Force
@'
@echo off
setlocal
cd /d "%~dp0"
if not exist return-evidence mkdir return-evidence
if not exist return-evidence\after mkdir return-evidence\after
recorder\ISphereLiveProbeRecorder.exe --no-pause > return-evidence\after\recorder-after.txt 2>&1
echo after recorder exit code: %ERRORLEVEL% > return-evidence\after\exit-code.txt
pause
exit /b 0
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-after-file-recorder.bat") -Encoding ASCII
Copy-Item -LiteralPath (Join-Path $packageDir "run-after-file-recorder.bat") -Destination (Join-Path $packageDir "02-run-after-file-recorder.bat") -Force
@'
@echo off
setlocal
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy Bypass -File .\CREATE-FILE-RETURN-ZIP.ps1
pause
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "03-create-file-return-zip.bat") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
echo R9 send-file recording suite
echo Step 1: before recorder
call 01-run-before-file-recorder.bat
echo.
echo Step 2: manually send exactly one sandbox file now.
echo Fill FILE-SEND-INPUTS.json before continuing.
pause
echo Step 3: after recorder
call 02-run-after-file-recorder.bat
echo.
echo Step 4: optional capability smoke
if not exist return-evidence mkdir return-evidence
capability\isphere-capability-smoke.exe > return-evidence\capability-smoke.txt 2>&1
echo capability smoke exit code: %ERRORLEVEL% > return-evidence\capability-smoke-exit-code.txt
echo.
echo Step 5: create return zip
call 03-create-file-return-zip.bat
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RUN-FILE-RECORDING-SUITE.bat") -Encoding ASCII
@'
{
"package": "send-file-sandbox-gate",
"LOCAL_LOGIN_UNAVAILABLE": true,
"ONLINE_SANDBOX_REQUIRED": true,
"MANUAL_ONE_FILE_SEND_ONLY": true,
"DO_NOT_SEND_SECOND_FILE": true,
"entrypoint": "RUN-FILE-RECORDING-SUITE.bat",
"input_template": "FILE-SEND-INPUTS.template.json",
"return_zip_script": "CREATE-FILE-RETURN-ZIP.ps1",
"recorder_exe": "recorder/ISphereLiveProbeRecorder.exe",
"capability_smoke_exe": "capability/isphere-capability-smoke.exe",
"expected_tool_count": 10,
"production_file_send_enabled": false
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-RECORDING-PACKAGE-MANIFEST.json") -Encoding UTF8
if (-not $NoZip) {
Compress-Archive -Path (Join-Path $packageDir "*") -DestinationPath $zipPath -Force
}
[ordered]@{
ok = $true
package_dir = (Resolve-Path -LiteralPath $packageDir).Path
zip = if (Test-Path -LiteralPath $zipPath) { (Resolve-Path -LiteralPath $zipPath).Path } else { $null }
recorder_exe = (Resolve-Path -LiteralPath (Join-Path $recorderDir "ISphereLiveProbeRecorder.exe")).Path
capability_smoke_exe = (Resolve-Path -LiteralPath $capabilityExe).Path
local_login_required = $false
online_sandbox_required = $true
production_file_send_enabled = $false
} | ConvertTo-Json -Depth 4 -Compress