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 8404 (#158) #159

Merged
merged 6 commits into from
Jun 24, 2024
Merged

ASA 8404 (#158) #159

merged 6 commits into from
Jun 24, 2024

Conversation

vishalhcl-5960
Copy link

* include SCA implementation
* copyright changes
@vishalhcl-5960 vishalhcl-5960 requested a review from mattmurp June 12, 2024 13:44
@@ -27,12 +27,13 @@ public interface CoreConstants {
String SCANNER_TYPE = "type"; //$NON-NLS-1$
String STATUS = "Status"; //$NON-NLS-1$
String TARGET = "target"; //$NON-NLS-1$
String OPEN_SOURCE_ONLY = "openSourceOnly"; //$NON-NLS-1$
String INCLUDE_SCA = "includeSCA"; //$NON-NLS-1$

Choose a reason for hiding this comment

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

The OPEN_SOURCE_ONLY constant is still used in various places within the code, so we should not be removing it. It could also be used by different plugins, so we should keep that constant in place.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, Matt.

String VERSION_NUMBER = "VersionNumber"; //$NON-NLS-1$
String USER_MESSAGE = "UserMessage"; //$NON-NLS-1$
String IS_VALID = "IsValid"; //$NON-NLS-1$
String SOURCE_CODE_ONLY = "sourceCodeOnly"; //$NON-NLS-1$
String SOFTWARE_COMPOSITION_ANALYZER = "Software Composition Analyzer"; //$NON-NLS-1$
String STATIC_ANALYZER = "Static Analyzer"; //$NON-NLS-1$

Choose a reason for hiding this comment

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

Both SOFTWARE_COMPOSITION_ANALYZER and STATIC_ANALYZER are already defined in the ScannerConstants interface, so we shouldn't duplicate those constants here.

Copy link
Author

Choose a reason for hiding this comment

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

As we have STATIC_ANALYZER constant in the SASTConstant interface, using the same in SAClient class.

Choose a reason for hiding this comment

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

Can you remove the constant here since it's a duplicate?

Copy link
Author

Choose a reason for hiding this comment

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

Done, Matt.

@@ -33,7 +33,11 @@ public ASoCScan(Map<String, String> properties, IScanServiceProvider provider) {
}

public ASoCScan(Map<String, String> properties, IProgress progress, IScanServiceProvider provider) {
m_target = properties.remove(CoreConstants.TARGET);
if(properties.containsKey(CoreConstants.INCLUDE_SCA)) {

Choose a reason for hiding this comment

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

What's the reason for keeping the TARGET property when the properties contains INCLUDE_SCA? We have a handle to that value through m_target.

Copy link
Author

Choose a reason for hiding this comment

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

If 2 scans are executing then this method is being called twice, so during the 2nd run it will throw me error as we had removed the TARGET parameter in the 1st run.

Choose a reason for hiding this comment

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

The behavior you're describing is specific to the Jenkins plugin that uses this SDK. A check for a constant called INCLUDE_SCA doesn't make sense here from the SDK perspective.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, will handle the same in plugin code.

@@ -326,16 +326,17 @@ private List<String> getClientArgs(Map<String, String> properties) {
if(properties.containsKey(VERBOSE)) {
args.add(OPT_VERBOSE);
}
if(properties.containsKey(THIRD_PARTY) || System.getProperty(THIRD_PARTY) != null) {
if(properties.containsKey(THIRD_PARTY) || System.getProperty(THIRD_PARTY) != null)

Choose a reason for hiding this comment

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

For consistency, we should keep the { } brackets rather than having some conditionals use them and others not.

Copy link
Author

Choose a reason for hiding this comment

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

sure, Matt.

if(properties.containsKey(SCAN_SPEED)) {
if (!properties.containsKey(CoreConstants.INCLUDE_SCA) && properties.get(CoreConstants.SCANNER_TYPE).equals(CoreConstants.STATIC_ANALYZER))
args.add(OPT_STATIC_ANALYSIS_ONLY);
if (!properties.containsKey(CoreConstants.INCLUDE_SCA) && properties.get(CoreConstants.SCANNER_TYPE).equals(CoreConstants.SOFTWARE_COMPOSITION_ANALYZER))

Choose a reason for hiding this comment

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

Is the first "if" check necessary here? !properties.containsKey(CoreConstants.INCLUDE_SCA)
If the scanner type is SCA, it shouldn't matter if that property is set or not.

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 can skip "includeSCA" check for the SCA scan as IRX generation will only take place if ApplicationFileId is not present in properties.

@@ -34,8 +34,12 @@ public void run() throws ScannerException, InvalidTargetException {
throw new InvalidTargetException(Messages.getMessage(TARGET_INVALID, target));

try {
generateIR();
analyzeIR();
if(getProperties().containsKey(CoreConstants.INCLUDE_SCA) && getProperties().containsKey("ApplicationFileId")) {

Choose a reason for hiding this comment

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

Since this is the SCAScan class, is there a reason to check if INCLUDE_SCA is set? It seems like that would be implied by the scan type.

Copy link
Author

Choose a reason for hiding this comment

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

For the implementation of include SCA, I am changing the SCANNER_TYPE parameter in the properties to SCA after the execution of 1st scan. This class will be called during the 2nd scan & with the INCLUDE_SCA check i am skipping the irx generation for the SCA execution as we have to utilize the same generated irx of the 1st scan.

Choose a reason for hiding this comment

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

Similar to the other comment, what you're describing is specific to the Jenkins plugin that uses the SDK. This behavior should be handled in that plugin, as opposed to 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 only check for the "ApplicationFileId" paramter, if it is there we would skip the IRX generation step for SCA scan.

@vishalhcl-5960 vishalhcl-5960 requested a review from mattmurp June 13, 2024 18:16
@vishalhcl-5960 vishalhcl-5960 merged commit 590c60a into master Jun 24, 2024
2 checks passed
@vishalhcl-5960 vishalhcl-5960 deleted the ASA-8404 branch August 1, 2024 08:42
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