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

Defect #2318019: [Fortify on Demand] Vulnerabilities are not injected… #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private PplnRunStatus fodScanIsStillInProgress(VulnerabilitiesQueueItem queueIte
return new PplnRunStatus(false, true);
}
}
if (getFailedTries(queueItem) > 10) {
if (getFailedTries(queueItem) > 100) {
logger.error(
"scan Id was not found, validate that the release in the pipeline configuration is the same as the release in the Jenkins job.");
return new PplnRunStatus(false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,23 @@
public abstract class FODConfig {

public final String authURL;
public final String authURLApi;
public final String entitiesURL;
public abstract String getAuthBody();

protected FODConfig(String baseURL){
protected FODConfig(String baseURL, String authURLApi){
String normalizeURLApi = authURLApi;
if(!normalizeURLApi.endsWith("/")){
normalizeURLApi = normalizeURLApi + "/";
}
this.authURLApi = normalizeURLApi + "oauth/token";

String normanlizedURL = baseURL;
if(!normanlizedURL.endsWith("/")){
normanlizedURL = normanlizedURL + "/";
}
this.authURL = normanlizedURL + "oauth/token";
this.entitiesURL = normanlizedURL + "api/v3";

this.entitiesURL = normalizeURLApi + "api/v3";
}


Expand All @@ -57,11 +62,11 @@ public static class PasswordFODConfig extends FODConfig{
String password;
String tenant;

static final String authPWDBodyFormat ="grant_type=password&scope=https://hpfod.com/tenant&username=%s\\%s&password=%s";
static final String authPWDBodyFormat ="grant_type=client_credentials&scope=api-tenant&client_id=%s&client_secret=%s";

public PasswordFODConfig(String baseUrl, String username, String password,String tenant) {
public PasswordFODConfig(String baseUrl, String authURLApi, String username, String password,String tenant) {

super(baseUrl);
super(baseUrl, authURLApi);
this.password = password;
this.username = username;
this.tenant = tenant;
Expand All @@ -74,12 +79,12 @@ public String getAuthBody(){

public static class CredentialsFODConfig extends FODConfig{

static final String authBodyFormat ="grant_type=client_credentials&scope=https://hpfod.com/tenant&client_id=%s&client_secret=%s";
static final String authBodyFormat ="grant_type=client_credentials&scope=api-tenant&client_id=%s&client_secret=%s";
String client_id;
String secret;
public CredentialsFODConfig(String baseUrl, String clientID, String secret){
public CredentialsFODConfig(String baseUrl,String authURLApi, String clientID, String secret){

super(baseUrl);
super(baseUrl, authURLApi);
this.client_id = clientID;
this.secret = secret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private String getUpdatedAccessToken() {

private void getAccessToken() {

HttpPost post = new HttpPost(fodConfig.authURL);
HttpPost post = new HttpPost(fodConfig.authURLApi);
HttpEntity content = new StringEntity(fodConfig.getAuthBody(), ContentType.APPLICATION_FORM_URLENCODED);

post.setEntity(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static SecurityTool getFODSecTool() {
FodServerConfiguration fodProjectConfiguration =
configurer.pluginServices.getFodServerConfiguration();
return new SecurityTool(fodProjectConfiguration.getBaseUrl(),
fodProjectConfiguration.getApiUrl(),
fodProjectConfiguration.getClientId(),
fodProjectConfiguration.getClientSecret());
}
Expand All @@ -86,6 +87,7 @@ private static FODSource createFodConnector(SecurityTool securityToolEntity) {
return new FodMockSource();
}else {
FODConnector instance = new FODConnector(new FODConfig.CredentialsFODConfig(securityToolEntity.getToolUrl(),
securityToolEntity.getToolUrlApi(),
securityToolEntity.getApiKey(),
securityToolEntity.getSecret()));
instance.initConnection(configurer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
public class SecurityTool {

private String toolUrl;
private String toolUrlApi;
private String apiKey;
private String secret;

public SecurityTool(String toolUrl, String apiKey, String secret) {
public SecurityTool(String toolUrl,String toolUrlApi, String apiKey, String secret) {
this.toolUrl = toolUrl;
this.toolUrlApi = toolUrlApi;
this.apiKey = apiKey;
this.secret = secret;
}
Expand All @@ -47,6 +49,10 @@ public String getToolUrl() {
return toolUrl;
}

public String getToolUrlApi() {
return toolUrlApi;
}

public String getApiKey() {
return apiKey;
}
Expand Down