Skip to content

Commit

Permalink
Merge pull request #155 from daniel-beck/SECURITY-3033
Browse files Browse the repository at this point in the history
[SECURITY-3033] Submit POST requests as needed
  • Loading branch information
GLundh authored Oct 31, 2023
2 parents e1335c9 + 67cabb6 commit 645b7df
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 220 deletions.
12 changes: 0 additions & 12 deletions src/main/java/com/sonyericsson/hudson/plugins/rebuild/Root.java

This file was deleted.

69 changes: 69 additions & 0 deletions src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.sonyericsson.rebuild;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.matrix.MatrixRun;
import hudson.model.Action;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Queue;
import hudson.model.Run;

public abstract class AbstractRebuildAction implements Action {

@Override
public String getIconFileName() {
if (isRebuildAvailable()) {

Check warning on line 15 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 15 is only partially covered, one branch is missing
return "clock.png";
} else {
return null;

Check warning on line 18 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 18 is not covered by tests
}
}

/**
* Method for checking whether the rebuild functionality would be available
* for build.
*
* @return boolean
*/
public boolean isRebuildAvailable() {
Job project = getProject();
return project != null

Check warning on line 30 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 30 is only partially covered, one branch is missing
&& project.hasPermission(Item.BUILD)

Check warning on line 31 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 31 is only partially covered, one branch is missing
&& project.isBuildable()

Check warning on line 32 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 32 is only partially covered, 2 branches are missing
&& project instanceof Queue.Task
&& !isMatrixRun()

Check warning on line 34 in src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 34 is only partially covered, one branch is missing
&& !isRebuildDisabled();

}

// Jelly
public abstract String getTaskUrl();

// Jelly
public abstract boolean isRequiresPOST();

private boolean isRebuildDisabled() {
RebuildSettings settings = getProject().getProperty(RebuildSettings.class);
return settings != null && settings.getRebuildDisabled();
}

/**
* Method will return current project.
*
* @return currentProject.
*/
public abstract Job<?, ?> getProject();

@CheckForNull
protected abstract Run<?, ?> getRun();

/**
* Method for checking whether current build is sub job(MatrixRun) of Matrix
* build.
*
* @return boolean
*/
public boolean isMatrixRun() {
return getRun() instanceof MatrixRun;
}
}
Loading

0 comments on commit 645b7df

Please sign in to comment.