Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
feat: whitelist some external but expected root config properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lachrist committed Jun 7, 2022
1 parent e6b6e2d commit ddbb914
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/validate/ajv/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import Treeify from "treeify";
import AjvErrorTree from "ajv-error-tree";
import { schema } from "../../../dist/schema.mjs";

const {ownKeys} = Reflect;
const { ownKeys } = Reflect;
const _Map = Map;
const { asTree } = Treeify;

const expected_extra_properties = ["appmap_dir"];

export default (dependencies) => {
const {
util: { hasOwnProperty, assert, coalesce },
expect: { expect },
log: {logGuardInfo},
log: { logGuardInfo },
} = dependencies;
const naming = new _Map([
["config", "configuration"],
Expand Down Expand Up @@ -42,14 +44,15 @@ export default (dependencies) => {
};
};
const validateConfig = generateValidate("config");
const config_schema = schema.find(({$id}) => $id === "config");
const config_schema = schema.find(({ $id }) => $id === "config");
return {
validateMessage: generateValidate("message"),
validateConfig: (config) => {
validateConfig(config);
for (const key of ownKeys(config)) {
logGuardInfo(
!hasOwnProperty(config_schema.properties, key),
!hasOwnProperty(config_schema.properties, key) &&
expected_extra_properties.includes(key),
"Configuration property not recognized by the agent: %j",
key,
);
Expand Down

0 comments on commit ddbb914

Please sign in to comment.