-
Notifications
You must be signed in to change notification settings - Fork 3
[Bug] Code changes for cleanup-list.schema.json #2
Description
Not a bug, but code corrections. I basically aligned it better to get-entities.
Changes first, full script at the end.
1. Incorrect structure of delete.type
Your schema:
"delete": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": "string",
"enum": ["file", "directory", "registry value", "registry key"]
}
},
"location": {
"type": "string"
}
}
}
Expected by script:
"delete": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["file", "directory", "registry value", "registry key"]
},
"location": {
"type": "string"
}
},
"required": ["type", "location"]
}
2. Incorrect type for description and properties
You defined:
"description": "object",
"properties": {
"type": "string"
}
"description": "object" is incorrect — that assigns a string literal "object" as a description field.
"properties" at this level is ambiguous and probably misused.
Fix:
Remove those entries unless you intend to describe additional sub-properties.
3. Location of active is incorrect
Your schema has active under delete:
"delete": {
...
"active": {
"type": "boolean"
}
}
But the script expects active at the top level of each rule:
$_.Value.active -eq $true
Fix: Move active to top-level in each rule object:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"application": { "type": "string" },
"category": {
"type": "string",
"enum": ["IDE", "government", "Windows", "Windows update", ".NET", "installer", "my application", "my files", "my registry entries", "AI", "communication", "game", "hardware", "editing software"]
},
"entity_category": {
"type": "string",
"enum": ["crash log", "log", "cache", "backup", "old version", "temporary files", "telemetry", "memory dump"]
},
"custom_category": { "type": "string" },
"description": { "type": "string" },
"instructions": { "type": "string" },
"delete": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["file", "directory", "registry value", "registry key"]
},
"location": { "type": "string" }
},
"required": ["type", "location"]
},
"active": { "type": "boolean" }
},
"required": ["application", "category", "entity_category", "description", "delete", "active"],
"additionalProperties": false
}
},
"additionalProperties": false
}
New version:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/constup/cleanup/blob/master/cleanup-list.schema.json",
"title": "constUP Cleanup list schema",
"description": "Describes cleanup operations on files, folders and registry entries for constUP Garbage Cleaner to use.",
"type": "object",
"patternProperties": {
"^[a-z0-9_]+$": {
"type": "object",
"properties": {
"application": {
"type": "string"
},
"category": {
"type": "string",
"enum": [
"IDE",
"government",
"Windows",
"Windows update",
".NET",
"installer",
"my application",
"my files",
"my registry entries",
"AI",
"communication",
"game",
"hardware",
"editing software"
]
},
"entity_category": {
"type": "string",
"enum": [
"crash log",
"log",
"cache",
"backup",
"old version",
"temporary files",
"telemetry",
"memory dump"
]
},
"custom_category": {
"type": "string"
},
"description": {
"type": "string"
},
"instructions": {
"type": "string"
},
"delete": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"file",
"directory",
"registry value",
"registry key"
]
},
"location": {
"type": "string"
}
},
"required": ["type", "location"],
"additionalProperties": false
},
"active": {
"type": "boolean"
}
},
"required": [
"application",
"category",
"entity_category",
"description",
"delete",
"active"
],
"additionalProperties": false
}
},
"additionalProperties": false
}