11// Runs security checks over plugin install candidates before activation.
2- import type { OpenClawConfig } from "../config/types.openclaw.js" ;
3- import type {
4- InstallPolicyOrigin ,
5- InstallPolicyRequestKind ,
6- InstallPolicySource ,
7- } from "../security/install-policy.js" ;
8- import type {
9- InstallPolicyWarningDetails ,
10- InstallSafetyOverrides ,
11- } from "./install-security-scan.types.js" ;
2+ import type { InstallPolicyWarningDetails } from "./install-security-scan.types.js" ;
123export type { InstallSafetyOverrides } from "./install-security-scan.types.js" ;
134
14- type InstallScanLogger = {
15- warn ?: ( message : string ) => void ;
16- } ;
17-
185/** Result returned by plugin/skill install security policy checks. */
196export type InstallSecurityScanResult = {
207 blocked ?: {
@@ -24,9 +11,6 @@ export type InstallSecurityScanResult = {
2411 } ;
2512} ;
2613
27- /** Plugin install request kinds that share install policy without skill install semantics. */
28- type PluginInstallRequestKind = Exclude < InstallPolicyRequestKind , "skill-install" > ;
29-
3014/** Skill install metadata shape passed into shared install policy evaluation. */
3115export type SkillInstallSpecMetadata = {
3216 id ?: string ;
@@ -51,60 +35,30 @@ async function loadInstallSecurityScanRuntime() {
5135
5236/** Scans an unpacked bundle source before plugin install/update. */
5337export async function scanBundleInstallSource (
54- params : InstallSafetyOverrides & {
55- config ?: OpenClawConfig ;
56- logger : InstallScanLogger ;
57- pluginId : string ;
58- sourceDir : string ;
59- requestKind ?: PluginInstallRequestKind ;
60- requestedSpecifier ?: string ;
61- mode ?: "install" | "update" ;
62- version ?: string ;
63- source ?: InstallPolicySource ;
64- } ,
38+ params : Parameters <
39+ typeof import ( "./install-security-scan.runtime.js" ) . scanBundleInstallSourceRuntime
40+ > [ 0 ] ,
6541) : Promise < InstallSecurityScanResult | undefined > {
6642 const { scanBundleInstallSourceRuntime } = await loadInstallSecurityScanRuntime ( ) ;
6743 return await scanBundleInstallSourceRuntime ( params ) ;
6844}
6945
7046/** Scans a package source directory and executable metadata before install/update. */
7147export async function scanPackageInstallSource (
72- params : InstallSafetyOverrides & {
73- config ?: OpenClawConfig ;
74- extensions : string [ ] ;
75- logger : InstallScanLogger ;
76- packageDir : string ;
77- pluginId : string ;
78- requestKind ?: PluginInstallRequestKind ;
79- requestedSpecifier ?: string ;
80- mode ?: "install" | "update" ;
81- packageName ?: string ;
82- manifestId ?: string ;
83- version ?: string ;
84- source ?: InstallPolicySource ;
85- trustedSourceLinkedOfficialInstall ?: boolean ;
86- } ,
48+ params : Parameters <
49+ typeof import ( "./install-security-scan.runtime.js" ) . scanPackageInstallSourceRuntime
50+ > [ 0 ] ,
8751) : Promise < InstallSecurityScanResult | undefined > {
8852 const { scanPackageInstallSourceRuntime } = await loadInstallSecurityScanRuntime ( ) ;
8953 return await scanPackageInstallSourceRuntime ( params ) ;
9054}
9155
9256/** Scans the installed package dependency tree after npm resolution. */
93- export async function scanInstalledPackageDependencyTree ( params : {
94- additionalPackageDirs ?: string [ ] ;
95- allowManagedNpmRootPackagePeerSymlinks ?: boolean ;
96- config ?: OpenClawConfig ;
97- dependencyScanRootDir ?: string ;
98- logger : InstallScanLogger ;
99- mode ?: "install" | "update" ;
100- onInstallPolicyWarning ?: InstallSafetyOverrides [ "onInstallPolicyWarning" ] ;
101- packageDir : string ;
102- pluginId : string ;
103- requestKind ?: PluginInstallRequestKind ;
104- requestedSpecifier ?: string ;
105- source ?: InstallPolicySource ;
106- trustedSourceLinkedOfficialInstall ?: boolean ;
107- } ) : Promise < InstallSecurityScanResult | undefined > {
57+ export async function scanInstalledPackageDependencyTree (
58+ params : Parameters <
59+ typeof import ( "./install-security-scan.runtime.js" ) . scanInstalledPackageDependencyTreeRuntime
60+ > [ 0 ] ,
61+ ) : Promise < InstallSecurityScanResult | undefined > {
10862 const { scanInstalledPackageDependencyTreeRuntime } = await loadInstallSecurityScanRuntime ( ) ;
10963 return await scanInstalledPackageDependencyTreeRuntime ( params ) ;
11064}
@@ -114,68 +68,40 @@ export async function scanInstalledPackageDependencyTree(params: {
11468 * Remove only with the matching runtime-postbuild legacy alias cleanup.
11569 */
11670export async function scanFileInstallSource (
117- params : InstallSafetyOverrides & {
118- config ?: OpenClawConfig ;
119- filePath : string ;
120- logger : InstallScanLogger ;
121- mode ?: "install" | "update" ;
122- pluginId : string ;
123- requestedSpecifier ?: string ;
124- source ?: InstallPolicySource ;
125- } ,
71+ params : Parameters <
72+ typeof import ( "./install-security-scan.runtime.js" ) . scanFileInstallSourceRuntime
73+ > [ 0 ] ,
12674) : Promise < InstallSecurityScanResult | undefined > {
12775 const { scanFileInstallSourceRuntime } = await loadInstallSecurityScanRuntime ( ) ;
12876 return await scanFileInstallSourceRuntime ( params ) ;
12977}
13078
13179/** Runs npm install policy checks before package install side effects. */
132- export async function preflightPluginNpmInstallPolicy ( params : {
133- config ?: OpenClawConfig ;
134- dangerouslyForceUnsafeInstall ?: boolean ;
135- logger : InstallScanLogger ;
136- mode ?: "install" | "update" ;
137- onInstallPolicyWarning ?: InstallSafetyOverrides [ "onInstallPolicyWarning" ] ;
138- packageName : string ;
139- pluginId ?: string ;
140- requestedSpecifier ?: string ;
141- source ?: InstallPolicySource ;
142- sourcePath : string ;
143- sourcePathKind : "file" | "directory" ;
144- } ) : Promise < InstallSecurityScanResult | undefined > {
80+ export async function preflightPluginNpmInstallPolicy (
81+ params : Parameters <
82+ typeof import ( "./install-security-scan.runtime.js" ) . preflightPluginNpmInstallPolicyRuntime
83+ > [ 0 ] ,
84+ ) : Promise < InstallSecurityScanResult | undefined > {
14585 const { preflightPluginNpmInstallPolicyRuntime } = await loadInstallSecurityScanRuntime ( ) ;
14686 return await preflightPluginNpmInstallPolicyRuntime ( params ) ;
14787}
14888
14989/** Runs git install policy checks before plugin install side effects. */
150- export async function preflightPluginGitInstallPolicy ( params : {
151- config ?: OpenClawConfig ;
152- dangerouslyForceUnsafeInstall ?: boolean ;
153- logger : InstallScanLogger ;
154- mode ?: "install" | "update" ;
155- onInstallPolicyWarning ?: InstallSafetyOverrides [ "onInstallPolicyWarning" ] ;
156- pluginId : string ;
157- requestedSpecifier ?: string ;
158- source ?: InstallPolicySource ;
159- sourcePath : string ;
160- } ) : Promise < InstallSecurityScanResult | undefined > {
90+ export async function preflightPluginGitInstallPolicy (
91+ params : Parameters <
92+ typeof import ( "./install-security-scan.runtime.js" ) . preflightPluginGitInstallPolicyRuntime
93+ > [ 0 ] ,
94+ ) : Promise < InstallSecurityScanResult | undefined > {
16195 const { preflightPluginGitInstallPolicyRuntime } = await loadInstallSecurityScanRuntime ( ) ;
16296 return await preflightPluginGitInstallPolicyRuntime ( params ) ;
16397}
16498
16599/** Evaluates shared install policy for skill-managed dependency installs. */
166- export async function evaluateSkillInstallPolicy ( params : {
167- config ?: OpenClawConfig ;
168- installId : string ;
169- installSpec ?: SkillInstallSpecMetadata ;
170- logger : InstallScanLogger ;
171- mode ?: "install" | "update" ;
172- onInstallPolicyWarning ?: InstallSafetyOverrides [ "onInstallPolicyWarning" ] ;
173- origin : InstallPolicyOrigin ;
174- requestedSpecifier ?: string ;
175- source ?: InstallPolicySource ;
176- skillName : string ;
177- sourceDir : string ;
178- } ) : Promise < InstallSecurityScanResult | undefined > {
100+ export async function evaluateSkillInstallPolicy (
101+ params : Parameters <
102+ typeof import ( "./install-security-scan.runtime.js" ) . evaluateSkillInstallPolicyRuntime
103+ > [ 0 ] ,
104+ ) : Promise < InstallSecurityScanResult | undefined > {
179105 const { evaluateSkillInstallPolicyRuntime } = await loadInstallSecurityScanRuntime ( ) ;
180106 return await evaluateSkillInstallPolicyRuntime ( params ) ;
181107}
0 commit comments