Skip to content

Commit c5a1c11

Browse files
committed
- Updated the files for publish the plugin
1 parent 96fa28d commit c5a1c11

File tree

7 files changed

+23
-26
lines changed

7 files changed

+23
-26
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<properties>
4545
<revision>1.0</revision>
46-
<changelist>-SNAPSHOT</changelist>
46+
<changelist></changelist>
4747
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
4848
<jenkins.baseline>2.516</jenkins.baseline>
4949
<jenkins.version>${jenkins.baseline}.3</jenkins.version>

src/main/java/io/jenkins/plugins/ApiService.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public static AuthResponse authenticate(String apiKey, TaskListener listener) {
2323
String authUrl = DEFAULT_AUTH_URL;
2424
URL url = new URL(authUrl);
2525

26-
listener.getLogger().println("Authenticating with API key..." + url);
27-
2826
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
2927
conn.setRequestMethod("POST");
3028
conn.setRequestProperty("Content-Type", "application/json");
@@ -34,14 +32,11 @@ public static AuthResponse authenticate(String apiKey, TaskListener listener) {
3432
json.put("apiKey", apiKey);
3533
String body = json.toString();
3634

37-
listener.getLogger().println("Auth Request Body: " + body);
38-
3935
try (OutputStream os = conn.getOutputStream()) {
4036
os.write(body.getBytes());
4137
}
4238

4339
int responseCode = conn.getResponseCode();
44-
listener.getLogger().println("Auth Response Code: " + responseCode);
4540

4641
if (responseCode != 200) {
4742
// Read error response
@@ -51,7 +46,7 @@ public static AuthResponse authenticate(String apiKey, TaskListener listener) {
5146
while ((line = reader.readLine()) != null) {
5247
errorResponse.append(line);
5348
}
54-
listener.error("Authentication failed: " + errorResponse.toString());
49+
listener.error("Authentication failed: " + errorResponse);
5550
}
5651
return null;
5752
}
@@ -65,8 +60,6 @@ public static AuthResponse authenticate(String apiKey, TaskListener listener) {
6560
}
6661
}
6762

68-
listener.getLogger().println("Auth Response Body: " + response);
69-
7063
// Parse response
7164
JSONObject responseJson = JSONObject.fromObject(response.toString());
7265
String accessToken = responseJson.getString("access_token");
@@ -136,8 +129,6 @@ public static String triggerScan(String token, String targetFile, List<String> s
136129

137130
String body = json.toString();
138131

139-
listener.getLogger().println("Request Body: " + body);
140-
141132
try (OutputStream os = conn.getOutputStream()) {
142133
os.write(body.getBytes());
143134
}
@@ -151,7 +142,7 @@ public static String triggerScan(String token, String targetFile, List<String> s
151142
while ((line = reader.readLine()) != null) {
152143
response.append(line);
153144
}
154-
listener.getLogger().println("API Response Body: " + response);
145+
// listener.getLogger().println("API Response Body: " + response);
155146
}
156147

157148
return response.toString();

src/main/java/io/jenkins/plugins/PipelineStepExecution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public boolean start() throws Exception {
8383
listener.getLogger().println("------ Pipeline Method ------");
8484

8585
if (creds != null) {
86-
listener.getLogger().println("Token ID: " + creds.getTokenId());
87-
listener.getLogger().println("Description: " + creds.getTokenDescription());
86+
// listener.getLogger().println("Token ID: " + creds.getTokenId());
87+
// listener.getLogger().println("Description: " + creds.getTokenDescription());
8888
EnvVars env = getContext().get(EnvVars.class);
8989

9090
FilePath ws = getContext().get(FilePath.class);

src/main/java/io/jenkins/plugins/SecurityCheckBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ public SecurityCheckBuilder(Secret token) {
3636
this.token = token;
3737
}
3838

39-
@DataBoundSetter
40-
public void setTargetFile(String targetFile) {
41-
this.targetFile = targetFile;
42-
}
43-
4439
public Secret getToken() {
4540
return token;
4641
}
@@ -49,6 +44,11 @@ public String getTargetFile() {
4944
return targetFile;
5045
}
5146

47+
@DataBoundSetter
48+
public void setTargetFile(String targetFile) {
49+
this.targetFile = targetFile;
50+
}
51+
5252
public boolean isCveScan() {
5353
return cveScan;
5454
}
@@ -111,15 +111,15 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
111111
);
112112

113113
if (creds == null) {
114-
listener.error("Error: Vigilnz Token credential not found with ID: " + credentialId);
114+
listener.error("Error: Vigilnz Token credential not found");
115115
return false;
116116
}
117117

118118
// Get the actual token value from the credential
119119
String tokenText = creds.getToken().getPlainText();
120120

121-
listener.getLogger().println("Credential ID: " + credentialId);
122-
listener.getLogger().println("Your Token from Plugin: " + tokenText);
121+
// listener.getLogger().println("Credential ID: " + credentialId);
122+
// listener.getLogger().println("Your Token from Plugin: " + tokenText);
123123
if (targetFile != null && !targetFile.trim().isEmpty()) {
124124
listener.getLogger().println("Target File: " + targetFile);
125125
} else {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public String getTokenDescription() {
5555
return tokenDescription;
5656
}
5757

58+
5859
// Descriptor for Jenkins UI
5960
@Symbol("vigilnzToken")
6061
@Extension
@@ -65,8 +66,8 @@ public String getDisplayName() {
6566
return "Vigilnz Security Token";
6667
}
6768

68-
public FormValidation doCheckToken(@QueryParameter Secret token) {
69-
if (token == null || Secret.toString(token).isEmpty()) {
69+
public FormValidation doCheckToken(@QueryParameter String token) {
70+
if (token == null || token.trim().isEmpty()) {
7071
return FormValidation.error("Field is required");
7172
}
7273
return FormValidation.ok();

src/main/java/io/jenkins/plugins/models/ApiResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.jenkins.plugins.models;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
35
import java.util.List;
46

7+
@JsonIgnoreProperties(ignoreUnknown = true)
58
public class ApiResponse {
69
private String message;
710
private String repositoryId;
@@ -82,6 +85,7 @@ public void setResults(List<Result> results) {
8285
}
8386

8487
// Nested classes
88+
@JsonIgnoreProperties(ignoreUnknown = true)
8589
public static class Result {
8690
private String scanType;
8791
private String projectName;

src/main/java/io/jenkins/plugins/utils/VigilnzConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
public class VigilnzConfig {
55

66
// Default URLs (for development)
7-
public static final String DEFAULT_AUTH_URL = "http://localhost:1337/auth/api-key";
8-
public static final String DEFAULT_SCAN_URL = "http://localhost:1337/scan-targets/multi-scan";
7+
public static final String DEFAULT_BASE_URL = "https://devapi.vigilnz.com";
8+
public static final String DEFAULT_AUTH_URL = DEFAULT_BASE_URL + "/auth/api-key";
9+
public static final String DEFAULT_SCAN_URL = DEFAULT_BASE_URL + "/scan-targets/multi-scan";
910

1011
}
1112

0 commit comments

Comments
 (0)