-
Notifications
You must be signed in to change notification settings - Fork 16
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
SCA Support (#116) #117
SCA Support (#116) #117
Changes from 5 commits
d998a8a
a96bb24
328429a
8e8c9e3
60f90f5
b9bfffa
7bfb46b
d6a8f46
7a29b9b
4a7bc2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import com.hcl.appscan.sdk.error.ScannerException; | ||
import com.hcl.appscan.sdk.logging.DefaultProgress; | ||
import com.hcl.appscan.sdk.logging.IProgress; | ||
import com.hcl.appscan.sdk.logging.Message; | ||
import com.hcl.appscan.sdk.scan.IScanServiceProvider; | ||
import com.hcl.appscan.sdk.scanners.ASoCScan; | ||
import com.hcl.appscan.sdk.utils.ArchiveUtil; | ||
|
@@ -73,7 +74,7 @@ public File getIrx() { | |
return m_irx; | ||
} | ||
|
||
private void generateIR() throws IOException, ScannerException { | ||
protected void generateIR() throws IOException, ScannerException { | ||
File targetFile = new File(getTarget()); | ||
|
||
//If we were given an irx file, don't generate a new one | ||
|
@@ -108,7 +109,7 @@ private void generateZip() throws IOException,ScannerException { | |
throw new ScannerException(Messages.getMessage(ERROR_GENERATING_ZIP, getScanLogs().getAbsolutePath())); | ||
} | ||
|
||
private void analyzeIR() throws IOException, ScannerException { | ||
protected void analyzeIR() throws IOException, ScannerException { | ||
if(getProperties().containsKey(PREPARE_ONLY)) | ||
return; | ||
|
||
|
@@ -117,9 +118,13 @@ private void analyzeIR() throws IOException, ScannerException { | |
throw new ScannerException(Messages.getMessage(ERROR_FILE_UPLOAD, m_irx.getName())); | ||
|
||
Map<String, String> params = getProperties(); | ||
params.put(ARSA_FILE_ID, fileId); | ||
|
||
setScanId(getServiceProvider().createAndExecuteScan(STATIC_ANALYZER, params)); | ||
params.put(FILE_ID, fileId); | ||
|
||
if(getType().equals(CoreConstants.SOFTWARE_COMPOSITION_ANALYZER)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest breaking this if/else case out into a separate method. In the SCAScan, you can override the method to do what we need for SCA. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, made the changes accordingly. |
||
setScanId(getServiceProvider().createAndExecuteScan(CoreConstants.SCA, params)); | ||
} else { | ||
setScanId(getServiceProvider().createAndExecuteScan(STATIC_ANALYZER, params)); | ||
} | ||
if(getScanId() == null) | ||
throw new ScannerException(Messages.getMessage(ERROR_SUBMITTING_IRX)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* © Copyright HCL Technologies Ltd. 2023. | ||
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package com.hcl.appscan.sdk.scanners.sca; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is almost identical to the existing SASTScan class. It would be better to extend SASTScan and adjust as needed than to copy the code into a new class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, will do accordingly. |
||
|
||
import com.hcl.appscan.sdk.CoreConstants; | ||
import com.hcl.appscan.sdk.Messages; | ||
import com.hcl.appscan.sdk.error.InvalidTargetException; | ||
import com.hcl.appscan.sdk.error.ScannerException; | ||
import com.hcl.appscan.sdk.logging.IProgress; | ||
import com.hcl.appscan.sdk.scan.IScanServiceProvider; | ||
import com.hcl.appscan.sdk.scanners.sast.SASTConstants; | ||
import com.hcl.appscan.sdk.scanners.sast.SASTScan; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class SCAScan extends SASTScan implements SASTConstants { | ||
private static final long serialVersionUID = 1L; | ||
private static final String REPORT_FORMAT = "html"; //$NON-NLS-1$ | ||
|
||
public SCAScan(Map<String, String> properties, IProgress progress, IScanServiceProvider provider) { | ||
super(properties, progress, provider); | ||
} | ||
|
||
@Override | ||
public void run() throws ScannerException, InvalidTargetException { | ||
String target = getTarget(); | ||
|
||
if(target == null || !(new File(target).exists())) | ||
throw new InvalidTargetException(Messages.getMessage(TARGET_INVALID, target)); | ||
|
||
try { | ||
generateIR(); | ||
analyzeIR(); | ||
} catch(IOException e) { | ||
throw new ScannerException(Messages.getMessage(SCAN_FAILED, e.getLocalizedMessage())); | ||
} | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return CoreConstants.SOFTWARE_COMPOSITION_ANALYZER; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* © Copyright HCL Technologies Ltd. 2023. | ||
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package com.hcl.appscan.sdk.scanners.sca; | ||
|
||
import com.hcl.appscan.sdk.CoreConstants; | ||
import com.hcl.appscan.sdk.auth.IAuthenticationProvider; | ||
import com.hcl.appscan.sdk.logging.IProgress; | ||
import com.hcl.appscan.sdk.scan.CloudScanServiceProvider; | ||
import com.hcl.appscan.sdk.scan.IScan; | ||
import com.hcl.appscan.sdk.scan.IScanFactory; | ||
import com.hcl.appscan.sdk.scan.IScanServiceProvider; | ||
|
||
import java.util.Map; | ||
|
||
public class SCAScanFactory implements IScanFactory { | ||
|
||
@Override | ||
public IScan create(Map<String, String> properties, IProgress progress, IAuthenticationProvider authProvider) { | ||
IScanServiceProvider serviceProvider = new CloudScanServiceProvider(progress, authProvider); | ||
return new SCAScan(properties, progress, serviceProvider); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return CoreConstants.SOFTWARE_COMPOSITION_ANALYZER; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
com.hcl.appscan.sdk.scanners.sast.SASTScanFactory | ||
com.hcl.appscan.sdk.scanners.dynamic.DASTScanFactory | ||
com.hcl.appscan.sdk.scanners.ase.ASEScanFactory | ||
com.hcl.appscan.sdk.scanners.sca.SCAScanFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a new class of HttpClient to accomodate the changes required for the support of SCA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be any need for that.