File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
main/java/org/jenkinsci/plugins/scriptsecurity/scripts
test/java/org/jenkinsci/plugins/scriptsecurity/scripts Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -706,16 +706,14 @@ public synchronized String[] getAclApprovedSignatures() {
706706 public synchronized void setApprovedScriptHashes (String [] scriptHashes ) throws IOException {
707707 Jenkins .getInstance ().checkPermission (Jenkins .RUN_SCRIPTS );
708708 approvedScriptHashes .clear ();
709- List <String > goodScriptHashes = new ArrayList <>(scriptHashes .length );
710- Pattern sha1Pattern = Pattern .compile ("^[a-fA-F0-9]{40}$" );
709+ Pattern sha1Pattern = Pattern .compile ("[a-fA-F0-9]{40}" );
711710 for (String scriptHash : scriptHashes ) {
712711 if (scriptHash != null && sha1Pattern .matcher (scriptHash ).matches ()) {
713- goodScriptHashes .add (scriptHash );
712+ approvedScriptHashes .add (scriptHash );
714713 } else {
715- LOG .warning ("Ignoring malformed script hash: " + scriptHash );
714+ LOG .warning (() -> "Ignoring malformed script hash: " + scriptHash );
716715 }
717716 }
718- approvedScriptHashes .addAll (goodScriptHashes );
719717 save ();
720718 reconfigure ();
721719 }
Original file line number Diff line number Diff line change @@ -172,6 +172,9 @@ public void upgradeSmokes() throws Exception {
172172 new SecureGroovyScript ("jenkins.model.Jenkins.instance" , true , null )));
173173 p .getPublishersList ().add (new TestGroovyRecorder (
174174 new SecureGroovyScript ("println(jenkins.model.Jenkins.instance.getLabels())" , false , null )));
175+ r .assertLogNotContains ("org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: "
176+ + "Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance" ,
177+ r .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ()));
175178 r .assertLogNotContains ("org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException: script not yet approved for use" ,
176179 r .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ()));
177180 }
You can’t perform that action at this time.
0 commit comments