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

ASA 7231 #131

Merged
merged 19 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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 @@ -218,13 +218,10 @@ private JSONObject getConfiguration(String format) throws JSONException {
}

private String getScanName() {
JSONObject obj;
try {
obj = m_scanProvider.getScanDetails(m_scanId);
return obj.getString("Name");
} catch (IOException | JSONException e) {
m_progress.setStatus(new Message(Message.ERROR, Messages.getMessage(ERROR_GETTING_DETAILS, e.getMessage())),
e);
return m_scanProvider.getScanExecutionName();
} catch (Exception e) {
m_progress.setStatus(new Message(Message.ERROR, Messages.getMessage(ERROR_GETTING_DETAILS, e.getMessage())), e);
return "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public String createAndExecuteScan(String type, Map<String, String> params) {
public String createAndExecuteScanWithJSONParameter(String type, JSONObject params) {
return "";
}

@Override

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can remove it from the ASE Provider as well.

public String getScanExecutionName() {return "";};

private String createJob(Map<String, String> params) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class CloudScanServiceProvider implements IScanServiceProvider, Serializa
private static final long serialVersionUID = 1L;

private IProgress m_progress;
private String scanExecutionName;
private IAuthenticationProvider m_authProvider;
private static final String[] DAST_FILES_EXTENSIONS = {DASTConstants.SCAN_EXTENSION, DASTConstants.SCANT_EXTENSION, DASTConstants.CONFIG_EXTENSION};

Expand All @@ -57,6 +58,7 @@ public String createAndExecuteScan(String type, Map<String, String> params) {
m_progress.setStatus(new Message(Message.INFO, Messages.getMessage(EXECUTING_SCAN)));
Map<String, String> request_headers = m_authProvider.getAuthorizationHeader(true);
HttpClient client = new HttpClient(m_authProvider.getProxy(), m_authProvider.getacceptInvalidCerts());
scanExecutionName = params.get("ScanName");

try {
HttpResponse response;
Expand Down Expand Up @@ -95,7 +97,7 @@ public String createAndExecuteScan(String type, Map<String, String> params) {
}

@Override
public String createAndExecuteScanWithJSONParameter(String type, JSONObject params) {
public String createAndExecuteScanWithJSONParameter(String type, JSONObject params) throws JSONException {
try {
if(loginExpired() || !verifyApplication(params.get(APP_ID).toString()))
return null;
Expand All @@ -106,6 +108,7 @@ public String createAndExecuteScanWithJSONParameter(String type, JSONObject para
m_progress.setStatus(new Message(Message.INFO, Messages.getMessage(EXECUTING_SCAN)));
Map<String, String> request_headers = m_authProvider.getAuthorizationHeader(true);
HttpClient client = new HttpClient(m_authProvider.getProxy(), m_authProvider.getacceptInvalidCerts());
scanExecutionName = params.getString("ScanName");

try {
HttpResponse response;
Expand Down Expand Up @@ -209,8 +212,13 @@ public JSONObject getScanDetails(String scanId) throws IOException, JSONExceptio

return null;
}

@Override

@Override

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for override if you remove the method from Interface.

public String getScanExecutionName() {
return scanExecutionName;
}

@Override
public JSONArray getNonCompliantIssues(String scanId) throws IOException, JSONException {
if(loginExpired())
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface IScanServiceProvider {
* @param params A JSON of scan parameters.
* @return The id of the submitted scan, if successful. Otherwise, null.
*/
public String createAndExecuteScanWithJSONParameter(String type, JSONObject params);
public String createAndExecuteScanWithJSONParameter(String type, JSONObject params) throws JSONException;

/**
* Submits a file for scanning.
Expand All @@ -59,7 +59,9 @@ public interface IScanServiceProvider {
* @throws JSONException If an error occurs.
*/
public JSONObject getScanDetails(String scanId) throws IOException, JSONException;


public String getScanExecutionName();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need this method here ?


/**
* Gets the non compliant issues in JSON format.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface DASTConstants {
String TEST_OPTIMIZATION_LEVEL = "TestOptimizationLevel"; //$NON-NLS-1$
String USER_NAME = "UserName"; //$NON-NLS-1$
String PASSWORD = "Password"; //$NON-NLS-1$
String EXTRA_FIELD = "ExtraField"; //$NON-NLS-1$
//Errors
String ERROR_SUBMITTING_SCAN = "error.submitting.scan"; //$NON-NLS-1$
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ private JSONObject createLogin(JSONObject json) throws JSONException {
login.put(USER_NAME, json.remove(LOGIN_USER));
login.put(PASSWORD, json.remove(LOGIN_PASSWORD));
}
if (json.containsKey(EXTRA_FIELD)) {
login.put(EXTRA_FIELD, json.remove(EXTRA_FIELD));
}
return login;
}

Expand Down
Loading