MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / fromPluginConfig

Method fromPluginConfig

config.ts:128–272  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

126 }
127
128 static fromPluginConfig(raw: unknown): PluginConfig {
129 const config = new PluginConfig();
130 if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
131 return config;
132 }
133
134 const layers = (raw as Record<string, unknown>).layers;
135 if (layers && typeof layers === "object") {
136 const foundationScan = (layers as Record<string, unknown>).foundationScan as Record<string, unknown> | undefined;
137 if (foundationScan) {
138 if (typeof foundationScan.enableFoundationScanDetection === "boolean")
139 config.layers.foundationScan.enableFoundationScanDetection = foundationScan.enableFoundationScanDetection;
140 if (typeof foundationScan.enableIntervention === "boolean")
141 config.layers.foundationScan.enableIntervention = foundationScan.enableIntervention;
142 if (typeof foundationScan.blockToolCallOnFoundationScanWarning === "boolean")
143 config.layers.foundationScan.blockToolCallOnFoundationScanWarning = foundationScan.blockToolCallOnFoundationScanWarning;
144
145 const detectMaliciousSkills = (foundationScan as Record<string, unknown>).detectMaliciousSkills as Record<string, unknown> | undefined;
146 if (detectMaliciousSkills) {
147 if (typeof detectMaliciousSkills.enable === "boolean")
148 config.layers.foundationScan.detectMaliciousSkills.enable = detectMaliciousSkills.enable;
149 if (typeof detectMaliciousSkills.ruleBasedDetection === "boolean")
150 config.layers.foundationScan.detectMaliciousSkills.ruleBasedDetection = detectMaliciousSkills.ruleBasedDetection;
151 if (typeof detectMaliciousSkills.semanticDetection === "boolean")
152 config.layers.foundationScan.detectMaliciousSkills.semanticDetection = detectMaliciousSkills.semanticDetection;
153 if (typeof detectMaliciousSkills.maxContentLength === "number" && detectMaliciousSkills.maxContentLength > 0)
154 config.layers.foundationScan.detectMaliciousSkills.maxContentLength = detectMaliciousSkills.maxContentLength;
155 if (typeof detectMaliciousSkills.maxConcurrency === "number" && detectMaliciousSkills.maxConcurrency > 0)
156 config.layers.foundationScan.detectMaliciousSkills.maxConcurrency = detectMaliciousSkills.maxConcurrency;
157 }
158
159 const detectMisConfiguration = (foundationScan as Record<string, unknown>).detectMisConfiguration as Record<string, unknown> | undefined;
160 if (detectMisConfiguration) {
161 if (typeof detectMisConfiguration.enable === "boolean")
162 config.layers.foundationScan.detectMisConfiguration.enable = detectMisConfiguration.enable;
163 }
164 }
165
166 const inputSanitization = (layers as Record<string, unknown>).inputSanitization as Record<string, unknown> | undefined;
167 if (inputSanitization) {
168 if (typeof inputSanitization.enableInputDetection === "boolean")
169 config.layers.inputSanitization.enableInputDetection = inputSanitization.enableInputDetection;
170 if (typeof inputSanitization.enableIntervention === "boolean")
171 config.layers.inputSanitization.enableIntervention = inputSanitization.enableIntervention;
172 if (typeof inputSanitization.temporaryBlockToolCall === "boolean")
173 config.layers.inputSanitization.temporaryBlockToolCall = inputSanitization.temporaryBlockToolCall;
174 if (typeof inputSanitization.blockHarmfulInput === "boolean")
175 config.layers.inputSanitization.blockHarmfulInput = inputSanitization.blockHarmfulInput;
176 if (typeof inputSanitization.coverContaminatedResponse === "boolean")
177 config.layers.inputSanitization.coverContaminatedResponse = inputSanitization.coverContaminatedResponse;
178 }
179
180 const cognitionProtection = (layers as Record<string, unknown>).cognitionProtection as Record<string, unknown> | undefined;
181 if (cognitionProtection) {
182 if (typeof cognitionProtection.enableMemWriteDetection === "boolean")
183 config.layers.cognitionProtection.enableMemWriteDetection = cognitionProtection.enableMemWriteDetection;
184 if (typeof cognitionProtection.enableIntervention === "boolean")
185 config.layers.cognitionProtection.enableIntervention = cognitionProtection.enableIntervention;

Callers 2

registerFunction · 0.80
parseFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected