Skip to content

Commit 3ab4ff1

Browse files
committed
fix(policy): reject unsupported tools policy stubs
1 parent 1ca7aa6 commit 3ab4ff1

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

extensions/policy/src/doctor/register.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,16 @@ describe("registerPolicyDoctorChecks", () => {
10051005
policy: { tools: { execPolicy: { allowHosts: ["sandbox"] } } },
10061006
target: "oc://policy.jsonc/tools/execPolicy",
10071007
},
1008+
{
1009+
label: "tools settings",
1010+
policy: { tools: { settings: {} } },
1011+
target: "oc://policy.jsonc/tools/settings",
1012+
},
1013+
{
1014+
label: "tools entries",
1015+
policy: { tools: { entries: [] } },
1016+
target: "oc://policy.jsonc/tools/entries",
1017+
},
10081018
{
10091019
label: "tools profile",
10101020
policy: { tools: { profiles: { deny: ["full"] } } },

extensions/policy/src/doctor/register.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,26 +1667,6 @@ export function policyContainerShapeFindings(
16671667
];
16681668
}
16691669
if (isRecord(policy.tools)) {
1670-
if (policy.tools.settings !== undefined && !isRecord(policy.tools.settings)) {
1671-
return [
1672-
policyShapeFinding(
1673-
policyPath,
1674-
`oc://${policyDocName}/tools/settings`,
1675-
`${policyPath} tools.settings must be an object.`,
1676-
`Fix ${policyPath} so tools.settings is an object.`,
1677-
),
1678-
];
1679-
}
1680-
if (policy.tools.entries !== undefined && !Array.isArray(policy.tools.entries)) {
1681-
return [
1682-
policyShapeFinding(
1683-
policyPath,
1684-
`oc://${policyDocName}/tools/entries`,
1685-
`${policyPath} tools.entries must be an array.`,
1686-
`Fix ${policyPath} so tools.entries is an array.`,
1687-
),
1688-
];
1689-
}
16901670
const postureFinding = toolPosturePolicyShapeFinding(policy.tools, {
16911671
policyDocName,
16921672
policyPath,
@@ -2568,12 +2548,10 @@ function toolPosturePolicyShapeFinding(
25682548
"alsoAllow",
25692549
"denyTools",
25702550
"elevated",
2571-
"entries",
25722551
"exec",
25732552
"fs",
25742553
"profiles",
25752554
"requireMetadata",
2576-
"settings",
25772555
];
25782556
const unsupportedTopLevel = unsupportedPolicyKey(tools, allowedTopLevel);
25792557
if (unsupportedTopLevel !== undefined) {

0 commit comments

Comments
 (0)