Skip to content

Commit

Permalink
final review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
markush81 committed Oct 13, 2024
1 parent d53d6c5 commit 1541fba
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/main/java/jenkins/plugins/office365connector/Webhook.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.Collections;
import java.util.List;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.Util;
Expand All @@ -31,13 +32,10 @@
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Webhook extends AbstractDescribableImpl<Webhook> {

public static final Integer DEFAULT_TIMEOUT = 30000;
private static final Logger log = LoggerFactory.getLogger(Webhook.class);

private String name;
private String url;
Expand All @@ -61,7 +59,7 @@ public class Webhook extends AbstractDescribableImpl<Webhook> {

@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
return (DescriptorImpl) super.getDescriptor();
}

@DataBoundConstructor
Expand Down Expand Up @@ -215,8 +213,8 @@ public FormValidation doCheckUrl(@QueryParameter String value) {
return FormUtils.formValidateUrl(value);
}

public FormValidation doCheckGlobalUrl(@QueryParameter String value) {
if(StringUtils.isNotBlank(value)) {
public FormValidation doCheckGlobalUrl(@QueryParameter String value) {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing POST/RequirePOST annotation Warning

Potential CSRF vulnerability: If DescriptorImpl#doCheckGlobalUrl connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doCheckGlobalUrl
if (StringUtils.isNotBlank(value)) {
return FormUtils.formValidateUrl(value);
} else {
return FormValidation.ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class AdaptiveCard implements Card {
private final String schema = "http://adaptivecards.io/schemas/adaptive-card.json";
@SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
private final String version = "1.4";
@SerializedName("msTeams")
private final MsTeams msteams = new MsTeams();
private final MsTeams msTeams = new MsTeams();
private final List<AdaptiveCardElement> body;
private List<CardAction> actions;

Expand Down Expand Up @@ -61,8 +60,8 @@ public String getVersion() {
return version;
}

public MsTeams getMsteams() {
return msteams;
public MsTeams getMsTeams() {
return msTeams;
}

public List<AdaptiveCardElement> getBody() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package jenkins.plugins.office365connector.model.adaptivecard;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class MsTeams {

@SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
private String width = "Full";

public String getWidth() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class Payload {

@SuppressFBWarnings(value = "SS_SHOULD_BE_STATIC")
private String type = "message";
private final List<Attachment> attachments = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.junit.Test;
import org.mockito.MockedStatic;

public class ActionablePotentialActionBuilderTest {
public class ActionableBuilderTest {

private static final String JOB_URL = "http://localhost/job/myFirstJob/167/display/redirect";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testAdaptiveCardStarted() {
notifier.sendBuildCompletedNotification();

// then
assertHasSameContent(workerData.get(0), FileUtils.getContentFile("adaptivecard_success.json"));
assertHasSameContent(workerData.get(0), FileUtils.getContentFile("adaptivecard-success.json"));
assertEquals(1, workerConstruction.constructed().size());
}

Expand All @@ -111,7 +111,7 @@ public void testAdaptiveCardStep() {
notifier.sendBuildStepNotification(stepParameters);

// then
assertHasSameContent(workerData.get(0), FileUtils.getContentFile("adaptivecard_step.json"));
assertHasSameContent(workerData.get(0), FileUtils.getContentFile("adaptivecard-step.json"));
assertEquals(1, workerConstruction.constructed().size());
}
}

0 comments on commit 1541fba

Please sign in to comment.