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 9675] DAST rescan #176

Merged
merged 15 commits into from
Dec 16, 2024
Merged

[ASA 9675] DAST rescan #176

merged 15 commits into from
Dec 16, 2024

Conversation

vishalhcl-5960
Copy link

Implementation of rescan functionality for the dynamic scans.

@vishalhcl-5960 vishalhcl-5960 mentioned this pull request Nov 26, 2024
@@ -123,9 +123,6 @@ public static void zipFileOrFolder(File fileToZip, File zipFile) throws IOExcept
}

private static void zipFile(File fileToZip, String fileName, ZipOutputStream zipOut) throws IOException {
if (fileToZip.getName().startsWith(".")) {
Copy link

Choose a reason for hiding this comment

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

What was the reason for the removal of this check?

Copy link
Author

@vishalhcl-5960 vishalhcl-5960 Dec 4, 2024

Choose a reason for hiding this comment

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

This change is being made to include the ".git" folder when creating a zip archive of the parent folder from a Git repository.
Task detail: https://jira02.hclpnp.com/browse/ASA-9830

* @param provider The IAuthenticationProvider for authentication.
* @return String.
*/
public static String getA360Version(IAuthenticationProvider provider) {
Copy link

Choose a reason for hiding this comment

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

There are a number of problems with this method:

  1. The javadoc comment is not accurate.
  2. The method name should just be getServiceVersion, not getA360Version.
  3. We shouldn't need a valid token to check the service version.
  4. We shouldn't need the authentication header.
  5. You should use "body.getString()" as opposed to casting.
  6. The comment in the catch block doesn't make sense.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, Made the suggested changes.

* @param provider The IAuthenticationProvider for authentication.
* @return JSONArray.
*/
public static JSONArray getExecutionDetails(String scanId, IAuthenticationProvider provider) {
Copy link

Choose a reason for hiding this comment

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

Why are there DAST specific checks here? The "IsValidForIncremental" property would only be true for DAST scans, but what if someone called this method for a SAST or SCA scan? This seems like a very specific method that is being added as a general utility method.

Copy link
Author

Choose a reason for hiding this comment

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

This method is used to fetch the "executionIds" which helps to fill the base scan dropdown field of incremental scan. I am renaming this method to "getBaseScanDetails" for better understanding.

* @param provider The IAuthenticationProvider for authentication.
* @return JSONObject.
*/
public static JSONObject scanSpecificDetails(String type, String scanId, IAuthenticationProvider provider) {
Copy link

Choose a reason for hiding this comment

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

The name of this method should be an action, like "getScanDetails()".

Copy link
Author

Choose a reason for hiding this comment

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

Sure, renaming the method to "getScanDetails()".

* @param provider The IAuthenticationProvider for authentication.
* @return JSONObject.
*/
public static JSONObject getScanDetails(String type, String scanId, IAuthenticationProvider provider) {
Copy link

Choose a reason for hiding this comment

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

What's the need for the addition of this method here when we already have the CloudScanServiceProvider that does the same thing?

Copy link
Author

@vishalhcl-5960 vishalhcl-5960 Dec 5, 2024

Choose a reason for hiding this comment

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

There is difference in the APIs. The method which is there in the CloudScanServiceProvider call the general API "GET /api/v4/Scans $filter=Id eq scanId" to fetch the scan details but new method of ServiceUtil calls the scan specific API "GET /api/v4/Sast/scanId ".
For scanId validation, We want to get the value of the "gitRepoPlatform" parameter which is not present in the respeonse of general API.

Copy link
Author

Choose a reason for hiding this comment

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

Matt, Should we move this new method into CloudScanServiceProvider class as it is perform related function?

* @param provider The IAuthenticationProvider for authentication.
* @return JSONArray.
*/
public static JSONArray getBaseScanDetails(String scanId, IAuthenticationProvider provider) {
Copy link

Choose a reason for hiding this comment

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

This method would be better as a part of the IScanServiceProvider (i.e. CloudScanServiceProvider) as opposed to being added as a utility method here.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I will move it to the cloudScanServiceProvider class.

*/
public static boolean isScanId(String scanId, String applicationId, String type, IAuthenticationProvider provider) {
public static void updateScanData(Map<String, String> params, String scanId, IAuthenticationProvider provider, IProgress progress) {
Copy link

Choose a reason for hiding this comment

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

Similar to the other comments, it's not clear why this is being added as a utility method, as opposed to the IScanServiceProvider that performs related functions.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I will move it to the cloudScanServiceProvider class.

return null;
}

public void updateScanData(Map<String, String> params, String scanId, IAuthenticationProvider provider, IProgress progress) {

Choose a reason for hiding this comment

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

Why does this method take an IAuthenticationProvider and an IProgress as parameters when there are already member variables of those types?

@vishalhcl-5960 vishalhcl-5960 changed the title DAST rescan [ASA 9675] DAST rescan Dec 16, 2024
@vishalhcl-5960 vishalhcl-5960 merged commit 0a9d637 into master Dec 16, 2024
2 checks passed
@vishalhcl-5960 vishalhcl-5960 deleted the DAST-rescan branch December 16, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants