mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-26 21:21:53 +08:00
fix(browser): improve transform mapping and browser analysis capabilities
CI / Test and build (push) Canceled after 0s
CI / Test and build (push) Canceled after 0s
This commit is contained in:
@@ -43,7 +43,8 @@ export const NETWORK_CAPABILITY_DOMAIN: CapabilityDomainDefinition = {
|
||||
|
||||
export const RECORDING_CAPABILITY_DOMAIN: CapabilityDomainDefinition = {
|
||||
id: 'recording-callable-debugger',
|
||||
owns: (method) => method.startsWith('browser.recording.')
|
||||
owns: (method) => method === 'browser.crypto.inspect'
|
||||
|| method.startsWith('browser.recording.')
|
||||
|| method.startsWith('browser.callable.')
|
||||
|| method.startsWith('browser.deep_capture.'),
|
||||
};
|
||||
|
||||
@@ -33,10 +33,28 @@ import {
|
||||
stageBrowserProfileEvidence,
|
||||
} from '@/features/browser-analysis/service';
|
||||
import { RECORDING_CAPABILITY_DOMAIN } from '../capability-domains';
|
||||
import { inspectPageCryptoOperation } from '@/features/browser-crypto/inspect';
|
||||
|
||||
export const recordingCapabilityHandler: CapabilityDomainHandler = {
|
||||
...RECORDING_CAPABILITY_DOMAIN,
|
||||
async handle({ method, input, grant }) {
|
||||
if (method === 'browser.crypto.inspect') {
|
||||
for (const scope of [
|
||||
'browser.recording.control',
|
||||
'browser.recording.sensitive.read',
|
||||
'browser.network.capture',
|
||||
'browser.network.sensitive.read',
|
||||
] as const) requireScope(grant, scope);
|
||||
return inspectPageCryptoOperation(
|
||||
await allowedTarget(grant, input),
|
||||
{
|
||||
captureId: String(input.captureId || ''),
|
||||
nodeId: String(input.nodeId || ''),
|
||||
settleMs: typeof input.settleMs === 'number' ? input.settleMs : undefined,
|
||||
},
|
||||
{ grantId: grant.id, expiresAt: grant.expiresAt },
|
||||
);
|
||||
}
|
||||
if (method.startsWith('browser.recording.')) {
|
||||
const target = await allowedTarget(grant, input);
|
||||
if (method === 'browser.recording.trace.list') {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
BrowserTransformExecuteInput,
|
||||
BrowserTransformPacket,
|
||||
BrowserTransformValidationExecuteInput,
|
||||
} from '@/types/models';
|
||||
import type { CapabilityDomainHandler } from '../capability-context';
|
||||
import { allowedTarget, requireScope } from '../capability-context';
|
||||
@@ -18,7 +19,10 @@ import {
|
||||
} from '@/features/browser-transform/service';
|
||||
import {
|
||||
compareBrowserPackets,
|
||||
browserTransformValidationById,
|
||||
executeBrowserTransformValidation,
|
||||
latestBrowserTransformValidation,
|
||||
prepareCapturedBrowserTransformProfile,
|
||||
proposeBrowserTransformProfile,
|
||||
validateInferredBrowserTransformProfile,
|
||||
} from '@/features/browser-analysis/service';
|
||||
@@ -27,6 +31,17 @@ import { TRANSFORM_CAPABILITY_DOMAIN } from '../capability-domains';
|
||||
export const transformCapabilityHandler: CapabilityDomainHandler = {
|
||||
...TRANSFORM_CAPABILITY_DOMAIN,
|
||||
async handle({ method, input, grant }) {
|
||||
if (method === 'browser.transform.prepare') {
|
||||
requireScope(grant, 'browser.recording.read');
|
||||
requireScope(grant, 'browser.callable.execute');
|
||||
return prepareCapturedBrowserTransformProfile(
|
||||
await allowedTarget(grant, input),
|
||||
String(input.candidateId || ''),
|
||||
input.packet as BrowserTransformPacket,
|
||||
Array.isArray(input.inputPaths) ? input.inputPaths.map(String) : undefined,
|
||||
typeof input.name === 'string' ? input.name : undefined,
|
||||
);
|
||||
}
|
||||
if (method === 'browser.packet.compare') {
|
||||
await allowedTarget(grant, input);
|
||||
return compareBrowserPackets(
|
||||
@@ -123,6 +138,17 @@ export const transformCapabilityHandler: CapabilityDomainHandler = {
|
||||
await allowedTarget(grant, profile.target);
|
||||
return deleteBrowserTransformProfile(profile.id);
|
||||
}
|
||||
if (method === 'browser.transform.validation.execute') {
|
||||
requireScope(grant, 'browser.transform.execute');
|
||||
const executeValidationInput = input as unknown as BrowserTransformValidationExecuteInput;
|
||||
const draft = await browserTransformValidationById(executeValidationInput.validationId);
|
||||
await allowedTarget(grant, draft.profile.target);
|
||||
return executeBrowserTransformValidation(
|
||||
executeValidationInput.validationId,
|
||||
executeValidationInput.direction,
|
||||
executeValidationInput.packet,
|
||||
);
|
||||
}
|
||||
const executeInput = input as unknown as BrowserTransformExecuteInput;
|
||||
const profile = await getBrowserTransformProfile(executeInput.profileId);
|
||||
await allowedTarget(grant, profile.target);
|
||||
|
||||
Reference in New Issue
Block a user