Skip to content

Commit 2d5adf7

Browse files
committed
- Added the filepath class in pipelineStep file and removed the doCheckTokenId method in TokenCredentials file
1 parent d20f241 commit 2d5adf7

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

src/main/java/io/jenkins/plugins/vigilnz/credentials/TokenCredentials.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -59,49 +59,49 @@ public String getDisplayName() {
5959
return "Vigilnz Security Token";
6060
}
6161

62-
// @POST
63-
// public FormValidation doCheckToken(@AncestorInPath Item item, @QueryParameter String token) {
64-
// Security: Check if user has permission to configure this item (project/folder)
65-
// If item is provided, check item permission; otherwise check global admin permission
66-
// if (item != null) {
67-
// if (!item.hasPermission(Item.CONFIGURE)) {
68-
// return FormValidation.error("No permission to configure this item");
69-
// }
70-
// } else {
71-
// // Global credential creation/editing requires admin permission
72-
// Jenkins.get().checkPermission(Jenkins.ADMINISTER);
73-
// }
74-
75-
// if (token == null || token.trim().isEmpty()) {
76-
// return FormValidation.error("Field is required");
77-
// }
78-
// return FormValidation.ok();
79-
// }
80-
81-
@POST
82-
public FormValidation doCheckTokenId(@AncestorInPath Item item, @QueryParameter String tokenId) {
83-
// Security: Check if user has permission to configure this item (project/folder)
84-
// If item is provided, check item permission; otherwise check global admin permission
85-
if (item != null) {
86-
if (!item.hasPermission(Item.CONFIGURE)) {
87-
return FormValidation.error("No permission to configure this item");
88-
}
89-
} else {
90-
// Global credential creation/editing requires admin permission
91-
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
92-
}
62+
// @POST
63+
// public FormValidation doCheckToken(@AncestorInPath Item item, @QueryParameter String token) {
64+
// Security: Check if user has permission to configure this item (project/folder)
65+
// If item is provided, check item permission; otherwise check global admin permission
66+
// if (item != null) {
67+
// if (!item.hasPermission(Item.CONFIGURE)) {
68+
// return FormValidation.error("No permission to configure this item");
69+
// }
70+
// } else {
71+
// // Global credential creation/editing requires admin permission
72+
// Jenkins.get().checkPermission(Jenkins.ADMINISTER);
73+
// }
74+
//
75+
// if (token == null || token.trim().isEmpty()) {
76+
// return FormValidation.error("Field is required");
77+
// }
78+
// return FormValidation.ok();
79+
// }
9380

94-
if (tokenId != null && !tokenId.trim().isEmpty()) {
95-
// Check for spaces
96-
if (tokenId.contains(" ")) {
97-
return FormValidation.error("ID must not contain spaces.");
98-
}
99-
// Optional: only allow letters, numbers, dash and underscore
100-
if (!tokenId.matches("^[a-zA-Z0-9_-]+$")) {
101-
return FormValidation.error("ID can only contain letters, numbers, - and _");
102-
}
103-
}
104-
return FormValidation.ok();
105-
}
81+
// @POST
82+
// public FormValidation doCheckTokenId(@AncestorInPath Item item, @QueryParameter String tokenId) {
83+
// // Security: Check if user has permission to configure this item (project/folder)
84+
// // If item is provided, check item permission; otherwise check global admin permission
85+
// if (item != null) {
86+
// if (!item.hasPermission(Item.CONFIGURE)) {
87+
// return FormValidation.error("No permission to configure this item");
88+
// }
89+
// } else {
90+
// // Global credential creation/editing requires admin permission
91+
// Jenkins.get().checkPermission(Jenkins.ADMINISTER);
92+
// }
93+
//
94+
// if (tokenId != null && !tokenId.trim().isEmpty()) {
95+
// // Check for spaces
96+
// if (tokenId.contains(" ")) {
97+
// return FormValidation.error("ID must not contain spaces.");
98+
// }
99+
// // Optional: only allow letters, numbers, dash and underscore
100+
// if (!tokenId.matches("^[a-zA-Z0-9_-]+$")) {
101+
// return FormValidation.error("ID can only contain letters, numbers, - and _");
102+
// }
103+
// }
104+
// return FormValidation.ok();
105+
// }
106106
}
107107
}

src/main/java/io/jenkins/plugins/vigilnz/pipeline/PipelineStep.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.jenkins.plugins.vigilnz.pipeline;
22

33
import hudson.Extension;
4+
import hudson.FilePath;
5+
import hudson.model.Run;
46
import hudson.model.TaskListener;
57
import jakarta.annotation.Nonnull;
68
import org.jenkinsci.plugins.workflow.steps.Step;
@@ -70,9 +72,14 @@ public String getDisplayName() {
7072
return "Run Vigilnz Security Scan";
7173
}
7274

75+
// @Override
76+
// public Set<? extends Class<?>> getRequiredContext() {
77+
// return Set.of(TaskListener.class);
78+
// }
79+
7380
@Override
7481
public Set<? extends Class<?>> getRequiredContext() {
75-
return Set.of(TaskListener.class);
82+
return Set.of(TaskListener.class, Run.class, FilePath.class);
7683
}
7784
}
7885

0 commit comments

Comments
 (0)