Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/vitest.terminal.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineConfig({
resolve: { preserveSymlinks: false },
test: {
resolveSnapshotPath,
globalSetup: ['./test/lib/termless/build-cli.mts'],
env: process.argv.some(arg => arg === '--update' || arg === '-u')
? { SOCKET_CLI_NATIVE_TEST_UPDATE_SNAPSHOTS: 'true' }
: {},
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,34 @@ jobs:
sea-downloads-v1-${{ matrix.target }}-

- name: Test screenshot and signing helpers
id: terminal-helpers
env:
SOCKET_CLI_NATIVE_TEST_ARTIFACTS: &terminal_artifacts build/terminal-test-artifacts/${{ matrix.target }}
NODE_OPTIONS: ${{ matrix.target == 'darwin-arm64' && '--max-old-space-size=4096' || '' }}
shell: bash
run: |
pnpm exec vitest run --config .config/vitest.config.mts test/unit/scripts/test/apple-signing.test.mts
pnpm exec vitest run --config .config/vitest.terminal.config.mts

- name: Show failed scan setup screenshots
if: failure() && steps.terminal-helpers.outcome == 'failure'
env:
SOCKET_CLI_NATIVE_TEST_ARTIFACTS: *terminal_artifacts
shell: bash
run: |
python - <<'PYTHON'
import os
import pathlib
import sys
import xml.etree.ElementTree as ET
sys.stdout.reconfigure(encoding='utf-8')
for svg in (pathlib.Path(os.environ['SOCKET_CLI_NATIVE_TEST_ARTIFACTS']) / 'npm-scan-setup').glob('*.svg'):
if svg.name in ('menu.svg', 'canceled.svg'):
print(svg.name)
for row in ET.parse(svg).iter('{http://www.w3.org/2000/svg}text'):
print(''.join(row.itertext()).rstrip())
PYTHON

- name: Verify .NET SDK
shell: bash
run: dotnet --list-sdks | awk -F. '$1 >= 8 { found=1 } END { exit !found }'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"@socketsecurity/config": "3.0.1",
"@socketsecurity/registry": "1.1.17",
"@socketsecurity/sdk": "4.0.3",
"@termless/vterm": "0.11.0",
"@termless/core": "0.11.0",
"@termless/xtermjs": "0.11.0",
"@types/blessed": "0.1.25",
Expand Down Expand Up @@ -309,6 +308,7 @@
"yargs-parser": "$yargs-parser"
},
"patchedDependencies": {
"@termless/core@0.11.0": "patches/@termless__core@0.11.0.patch",
"graceful-fs@4.2.11": "patches/graceful-fs@4.2.11.patch",
"string_decoder@0.10.31": "patches/string_decoder@0.10.31.patch",
"meow@13.2.0": "patches/meow@13.2.0.patch",
Expand Down
13 changes: 13 additions & 0 deletions patches/@termless__core@0.11.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dist/backends-CRpWNI-T.mjs b/dist/backends-CRpWNI-T.mjs
index 81de773c4f73a2b4c53ecb5249d906c21b4ebdfe..7504a072f7b3d63a69318b1947d0d45d4d184a99 100644
--- a/dist/backends-CRpWNI-T.mjs
+++ b/dist/backends-CRpWNI-T.mjs
@@ -113,7 +113,7 @@ function spawnNodePty(options) {
kill(signal) {
const sig = signal === 1 ? "SIGHUP" : signal === 9 ? "SIGKILL" : "SIGTERM";
try {
- ptyProcess.kill(sig);
+ ptyProcess.kill(process.platform === "win32" ? undefined : sig);
} catch {}
},
get exitCode() {
33 changes: 8 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions scripts/refresh/snapshots.mts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import type { SpawnSyncOptions } from 'node:child_process'
import { spawnSync } from 'node:child_process'
import { promises as fs } from 'node:fs'
import path from 'node:path'
import process from 'node:process'

import { isMainModule } from '../lib/is-main-module.mts'
import type { ScriptMeta } from '../lib/run-main.mts'
import { runMain } from '../lib/run-main.mts'
import type { SnapshotDependencyName } from './snapshots/dependencies.mts'
import {
SNAPSHOT_DEPENDENCIES,
assertSnapshotDependenciesCurrent,
normalizeSnapshotDependencyName,
} from './snapshots/dependencies.mts'

import type { ScriptMeta } from '../lib/run-main.mts'
import type { SnapshotDependencyName } from './snapshots/dependencies.mts'
import type { SpawnSyncOptions } from 'node:child_process'

const ROOT = path.resolve(import.meta.dirname, '../..')
const ARTIFACTS_ROOT = path.join(ROOT, 'build/native-test-artifacts')
const LOCK_DIR = path.join(ARTIFACTS_ROOT, '.snapshot-run-lock')
Expand Down
3 changes: 1 addition & 2 deletions scripts/test/native.mts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { SEA_VERSION } from '../../src/sea/version.mts'

import type { SpawnSyncOptions } from 'node:child_process'
import { spawnSync } from 'node:child_process'
import { createHash } from 'node:crypto'
import { promises as fs } from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import process from 'node:process'
import { SEA_VERSION } from '../../src/sea/version.mts'
import { isMainModule } from '../lib/is-main-module.mts'
import type { ScriptMeta } from '../lib/run-main.mts'
import { runMain } from '../lib/run-main.mts'
Expand Down
49 changes: 37 additions & 12 deletions src/commands/scan/cmd-scan-reach.test.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { once } from 'node:events'
import { createServer } from 'node:http'
import path from 'node:path'

import { describe, expect, it } from 'vitest'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'

import constants, {
FLAG_CONFIG,
Expand Down Expand Up @@ -655,6 +657,29 @@ describe('socket scan reach', async () => {
)

describe('non dry-run tests', () => {
const api = createServer((_request, response) => {
response.writeHead(401, { 'content-type': 'application/json' })
response.end(JSON.stringify({ message: 'Invalid test token' }))
})

beforeAll(async () => {
api.listen(0, '127.0.0.1')
await once(api, 'listening')
})
afterAll(async () => {
await api[Symbol.asyncDispose]()
})

function runWithInvalidToken(cmd: string[]) {
const address = api.address()
if (!address || typeof address === 'string') {
throw new Error('Expected a local test API port')
}
return spawnSocketCli(binCliPath, cmd, {
env: { SOCKET_CLI_API_BASE_URL: `http://127.0.0.1:${address.port}` },
})
}

cmdit(
[
'scan',
Expand All @@ -667,7 +692,7 @@ describe('socket scan reach', async () => {
],
'should handle reach analysis on test fixture',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
// Should fail due to fake token/org, but validates command parsing.
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
Expand All @@ -689,7 +714,7 @@ describe('socket scan reach', async () => {
],
'should handle npm ecosystem specification',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand All @@ -710,7 +735,7 @@ describe('socket scan reach', async () => {
],
'should handle custom memory limit',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand All @@ -731,7 +756,7 @@ describe('socket scan reach', async () => {
],
'should handle custom timeout',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand All @@ -752,7 +777,7 @@ describe('socket scan reach', async () => {
],
'should handle path exclusions',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand All @@ -772,10 +797,10 @@ describe('socket scan reach', async () => {
],
'should handle analytics disabled',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
expect(output).toContain('401')
},
)

Expand All @@ -792,7 +817,7 @@ describe('socket scan reach', async () => {
],
'should handle cache skipping',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand All @@ -812,7 +837,7 @@ describe('socket scan reach', async () => {
],
'should handle JSON output format',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
// JSON output typically suppresses banner in stderr.
const output = stdout + stderr
Expand All @@ -833,7 +858,7 @@ describe('socket scan reach', async () => {
],
'should handle markdown output format',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
// Markdown output typically suppresses banner in stderr.
const output = stdout + stderr
Expand All @@ -860,7 +885,7 @@ describe('socket scan reach', async () => {
],
'should handle comprehensive flag combination',
async cmd => {
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
const { code, stderr, stdout } = await runWithInvalidToken(cmd)
expect(code).toBeGreaterThan(0)
const output = stdout + stderr
expect(output.length).toBeGreaterThan(0)
Expand Down
Loading
Loading