Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY-3033] Submit POST requests as needed #155

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/main/java/com/sonyericsson/hudson/plugins/rebuild/Root.java

This file was deleted.

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()) {
return "clock.png";
} else {
return null;
}
}

/**
* Method for checking whether the rebuild functionality would be available
* for build.
*
* @return boolean
*/
public boolean isRebuildAvailable() {
Job project = getProject();
return project != null
&& project.hasPermission(Item.BUILD)
&& project.isBuildable()
&& project instanceof Queue.Task
&& !isMatrixRun()
&& !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