Class DefaultIqClient
java.lang.Object
org.sonatype.gradle.plugins.scan.nexus.iq.client.impl.DefaultIqClient
- All Implemented Interfaces:
IqClient
Default implementation of
IqClient.- Since:
- 1.0.1
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultIqClient(com.sonatype.insight.brain.client.ConfigurationClient configurationClient, ScannerFactory scannerFactory, com.sonatype.insight.brain.client.RestClientFactory.RestClient restClient, ReportClientFactory reportClientFactory, Optional<org.slf4j.Logger> log, Optional<String> instanceId) Constructs a new DefaultIqClient with the specified dependencies and configuration. -
Method Summary
Modifier and TypeMethodDescriptionevaluateApplication(String applicationId, String stageId, ScanResult scanResult, File scanFolder, File jsonResultsFile) Evaluates the scanned application and returns the policy evaluation result.Fetches the proprietary config for the given application.scan(String applicationId, ProprietaryConfig proprietaryConfig, Properties properties, List<File> scanTargets, File scanFolder, Map<String, String> envVars, Set<String> licensedFeatures, List<com.sonatype.insight.scan.module.model.Module> modules) Scans components found in the given lists of files and modules using Sonatype IQ Server.voidvalidateServerVersion(String minimalServerVersionRequired) Validates the minimal IQ Server version required.booleanverifyOrCreateApplication(String applicationPublicId, String organizationId) Verifies the applicationPublicId and if such an application does not exist and automatic application creation is enabled, then the method creates the new application under the given organization id and returns true to indicate the application will now be available.
-
Constructor Details
-
DefaultIqClient
public DefaultIqClient(com.sonatype.insight.brain.client.ConfigurationClient configurationClient, ScannerFactory scannerFactory, com.sonatype.insight.brain.client.RestClientFactory.RestClient restClient, ReportClientFactory reportClientFactory, Optional<org.slf4j.Logger> log, Optional<String> instanceId) Constructs a new DefaultIqClient with the specified dependencies and configuration.
-
-
Method Details
-
validateServerVersion
Description copied from interface:IqClientValidates the minimal IQ Server version required.- Specified by:
validateServerVersionin interfaceIqClient- Parameters:
minimalServerVersionRequired- the minimal server version to validate against- Throws:
IqClientException- when communication with IQ Server cannot be performed
-
verifyOrCreateApplication
public boolean verifyOrCreateApplication(String applicationPublicId, String organizationId) throws IqClientException Description copied from interface:IqClientVerifies the applicationPublicId and if such an application does not exist and automatic application creation is enabled, then the method creates the new application under the given organization id and returns true to indicate the application will now be available.- Specified by:
verifyOrCreateApplicationin interfaceIqClient- Parameters:
applicationPublicId- the application public ID to verifyorganizationId- the organization under which the app will be created- Returns:
- true to indicate the application is verified
- Throws:
IqClientException- when communication with IQ Server cannot be performed
-
getProprietaryConfigForApplicationEvaluation
public ProprietaryConfig getProprietaryConfigForApplicationEvaluation(String appId) throws IqClientException Description copied from interface:IqClientFetches the proprietary config for the given application.- Specified by:
getProprietaryConfigForApplicationEvaluationin interfaceIqClient- Parameters:
appId- the application public ID- Returns:
- the proprietary configuration containing packages and regexes to exclude
- Throws:
IqClientException- when communication with IQ Server cannot be performed
-
scan
public ScanResult scan(String applicationId, ProprietaryConfig proprietaryConfig, Properties properties, List<File> scanTargets, File scanFolder, Map<String, String> envVars, Set<String> licensedFeatures, List<com.sonatype.insight.scan.module.model.Module> modules) throws IqClientExceptionDescription copied from interface:IqClientScans components found in the given lists of files and modules using Sonatype IQ Server.- Specified by:
scanin interfaceIqClient- Parameters:
applicationId- Public application ID from IQ Server.proprietaryConfig- Configuration to exclude known proprietary components.properties- Configuration properties for the scan.scanTargets- List of files to scan.scanFolder- Base directory of the project or binary being scanned.envVars- Environmental variables for the scan.licensedFeatures- IQ licensed features.modules- List of modules to scan.- Returns:
ScanResultinstance with the scan results.- Throws:
IqClientException- If there is an error during the scan process.
-
evaluateApplication
public ApplicationPolicyEvaluation evaluateApplication(String applicationId, String stageId, ScanResult scanResult, File scanFolder, File jsonResultsFile) throws IqClientException Description copied from interface:IqClientEvaluates the scanned application and returns the policy evaluation result.- Specified by:
evaluateApplicationin interfaceIqClient- Parameters:
applicationId- the application public IDstageId- the stage ID for evaluationscanResult- the scan result from a previous scanscanFolder- the base directory used during scanningjsonResultsFile- optional file to write JSON results to- Returns:
- the policy evaluation result
- Throws:
IqClientException- when communication with IQ Server cannot be performed
-