java.lang.Object
org.sonatype.gradle.plugins.scan.nexus.iq.client.impl.DefaultIqClient
All Implemented Interfaces:
IqClient

public class DefaultIqClient extends Object implements IqClient
Default implementation of IqClient.
Since:
1.0.1
  • 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

      public void validateServerVersion(String minimalServerVersionRequired) throws IqClientException
      Description copied from interface: IqClient
      Validates the minimal IQ Server version required.
      Specified by:
      validateServerVersion in interface IqClient
      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: IqClient
      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.
      Specified by:
      verifyOrCreateApplication in interface IqClient
      Parameters:
      applicationPublicId - the application public ID to verify
      organizationId - 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: IqClient
      Fetches the proprietary config for the given application.
      Specified by:
      getProprietaryConfigForApplicationEvaluation in interface IqClient
      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 IqClientException
      Description copied from interface: IqClient
      Scans components found in the given lists of files and modules using Sonatype IQ Server.
      Specified by:
      scan in interface IqClient
      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:
      ScanResult instance 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: IqClient
      Evaluates the scanned application and returns the policy evaluation result.
      Specified by:
      evaluateApplication in interface IqClient
      Parameters:
      applicationId - the application public ID
      stageId - the stage ID for evaluation
      scanResult - the scan result from a previous scan
      scanFolder - the base directory used during scanning
      jsonResultsFile - optional file to write JSON results to
      Returns:
      the policy evaluation result
      Throws:
      IqClientException - when communication with IQ Server cannot be performed