jenkinsci / jenkinsci/script-security-plugin
[JENKINS-69452] JCasC JSON Schema output lacks scriptApproval properties
- Dominant language
- Java
- Stars
- 76
- Forks
- 181
- Avg merge
- 14h 55m
- Merged PRs (30d)
- 3
Description
The JSON Schema output for this plugin lacks the "approvedSignatures" and "approvedSignatureHashes properties. As a result, valid JCasC files fail JSON Schema validation.
Steps to reproduce:
- Install JCasC plugin and script-security plugin.
- Download the JCasC JSON Schema document for the Jenkins server: https://jenkins.example.com/configuration-as-code/schema
- Use the JSON Schema to validate some trivial JCasC samples. Here is one small JCasC sample that fails to validate:
```
---
security:
scriptApproval:
approvedSignatures:
- method hudson.model.Job getNextBuildNumber```
Actual results:
The JSON Schema document has this:
"scriptApproval": {
"additionalProperties": false,
"type": "object",
"properties": {
"approvedSignatures": {
"description": "",
"additionalProperties": false,
"type": "array",
"$id": "#/definitions/org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval"
}}
},
This means validation will fail on the user's approvedSignatures parameter.
Expected results
The JSON Schema needs to have these properties instead:
"scriptApproval": {
"additionalProperties": false,
"type": "object",
"$id": "#/definitions/org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval",
"properties": {
"approvedSignatures": {
"type": "array"
},
"approvedSignatureHashes": {
"type": "array"
}
}
},
Additional info
You can use a variety of tools to perform JSON Schema validation on JCasC YAML. Here's a Python script we use to do it:
import json
from jsonschema import validate
import yaml# Load the JSON Schema doc downloaded earlier
# from $JENKINS_URL/configuration-as-code/schema
with open('jenkins-casc-schema.json') as f:
schema = json.load(f)
f.close()
with open('casc.yaml') as d:
yaml_data = yaml.full_load(d)# Validate the user's casc.yaml with the JSON Schema:
validate(instance=yaml_data, schema=schema)
The error from this script is:
```
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('approvedSignatures' was unexpected)
```
---
Originally reported by ktdreyer, imported from: JCasC JSON Schema output lacks scriptApproval properties
Raw content of original issue
The JSON Schema output for this plugin lacks the "approvedSignatures" and "approvedSignatureHashes properties. As a result, valid JCasC files fail JSON Schema validation.
Steps to reproduce:
- Install JCasC plugin and script-security plugin.
- Download the JCasC JSON Schema document for the Jenkins server: https://jenkins.example.com/configuration-as-code/schema
- Use the JSON Schema to validate some trivial JCasC samples. Here is one small JCasC sample that fails to validate:
---
security:
scriptApproval:
approvedSignatures:
- method hudson.model.Job getNextBuildNumberActual results:
The JSON Schema document has this:
"scriptApproval": {
"additionalProperties": false,
"type": "object",
"properties": {
"approvedSignatures": {
"description": "",
"additionalProperties": false,
"type": "array",
"$id": "#/definitions/org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval"
}}
},This means validation will fail on the user's approvedSignatures parameter.
Expected results
The JSON Schema needs to have these properties instead:
"scriptApproval": {
"additionalProperties": false,
"type": "object",
"$id": "#/definitions/org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval",
"properties": {
"approvedSignatures": {
"type": "array"
},
"approvedSignatureHashes": {
"type": "array"
}
}
},Additional info
You can use a variety of tools to perform JSON Schema validation on JCasC YAML. Here's a Python script we use to do it:
import json
from jsonschema import validate
import yaml# Load the JSON Schema doc downloaded earlier
# from $JENKINS_URL/configuration-as-code/schema
with open('jenkins-casc-schema.json') as f:
schema = json.load(f)
f.close()
with open('casc.yaml') as d:
yaml_data = yaml.full_load(d)# Validate the user's casc.yaml with the JSON Schema:
validate(instance=yaml_data, schema=schema)The error from this script is:
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('approvedSignatures' was unexpected)
environment
```
script-security plugin version 1138.v8e727069a_025
JCasC plugin 1414.v878271fc496f
```
Contributor guide
Assessment
This issue has not been assessed yet.