All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.checkmarx.sdk.service.CxClient Maven / Gradle / Ivy

There is a newer version: 0.4.47
Show newest version
package com.checkmarx.sdk.service;

import com.checkmarx.sdk.dto.Filter;
import com.checkmarx.sdk.dto.ScanResults;
import com.checkmarx.sdk.dto.cx.CxProject;
import com.checkmarx.sdk.dto.cx.CxScanParams;
import com.checkmarx.sdk.dto.cx.CxScanSummary;
import com.checkmarx.sdk.dto.cx.xml.CxXMLResultsType;
import com.checkmarx.sdk.exception.CheckmarxException;
import org.json.JSONObject;

import java.io.File;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * Class used to orchestrate submitting scans and retrieving results
 */
public interface CxClient {

    public Integer getLastScanId(Integer projectId);

    /**
     * Fetches scan data based on given scan identifier, as a {@link JSONObject}.
     * @param scanId scan ID to use
     * @return  populated {@link JSONObject} if scan data was fetched; empty otherwise.
     */
    public JSONObject getScanData(String scanId);

    public LocalDateTime getLastScanDate(Integer projectId);

    /**
     * Get the status of a given scanId
     *
     * @param scanId
     * @return
     */
    Integer getScanStatus(Integer scanId);

    /**
     * Generate a scan report request (xml) based on ScanId
     *
     * @param scanId
     * @return
     */
    Integer createScanReport(Integer scanId);

    /**
     * Get the status of a report being generated by reportId
     *
     * @param reportId
     * @return
     */
    Integer getReportStatus(Integer reportId);

    /**
     * Retrieve the report by reportId, mapped to ScanResults DTO, applying filtering as requested
     *
     * @param reportId
     * @param filter
     * @return
     * @throws CheckmarxException
     */
    public ScanResults getReportContent(Integer reportId, List filter) throws CheckmarxException;

    /**
     * Retrieve the xml report by reportId, mapped to ScanResults DTO, applying filtering as requested
     *
     * @param reportId
     * @return
     * @throws CheckmarxException
     */
    public CxXMLResultsType getXmlReportContent(Integer reportId) throws CheckmarxException;


    /**
     * Returns custom field values read from a Checkmarx project, based on given projectId.
     *
     * @param projectId ID of project to lookup from Checkmarx
     * @return Map of custom field names to values
     */
    public Map getCustomFields(String projectId);

    /**
     * Parse CX report file, mapped to ScanResults DTO, applying filtering as requested
     *
     * @param file
     * @param filter
     * @return
     * @throws CheckmarxException
     */
    public ScanResults getReportContent(File file, List filter) throws CheckmarxException;

    /**
     * @param vulnsFile
     * @param libsFile
     * @param filter
     * @return
     * @throws CheckmarxException
     */
    public ScanResults getOsaReportContent(File vulnsFile, File libsFile, List filter) throws CheckmarxException;


    public String getIssueDescription(Long scanId, Long pathId);

    public Integer createProject(String ownerId, String name);


    /**
     * Get All Projects in Checkmarx
     *
     * @return
     */
    public List getProjects() throws CheckmarxException;

    /**
     * Get All Projects in Checkmarx
     *
     * @return
     */
    public List getProjects(String teamId) throws CheckmarxException;

    /**
     * Get All Projects under a specific team within Checkmarx
     * 

* using TeamId does not work. * * @param ownerId * @return */ public Integer getProjectId(String ownerId, String name); /** * Return Project based on projectId * * @return */ public CxProject getProject(Integer projectId); /** * Check if a scan exists for a projectId * * @param projectId * @return */ public boolean scanExists(Integer projectId); /** * Create Scan Settings * * @param projectId * @param presetId * @param engineConfigId * @return */ public Integer createScanSetting(Integer projectId, Integer presetId, Integer engineConfigId); /** * Set Repository details for a project * * @param projectId * @param gitUrl * @param branch * @throws CheckmarxException */ public void setProjectRepositoryDetails(Integer projectId, String gitUrl, String branch) throws CheckmarxException; /** * Upload file (zip of source) for a project * * @param projectId * @param file * @throws CheckmarxException */ public void uploadProjectSource(Integer projectId, File file) throws CheckmarxException; public void setProjectExcludeDetails(Integer projectId, List excludeFolders, List excludeFiles); /** * Get teamId for given path * * @param teamPath * @return * @throws CheckmarxException */ public String getTeamId(String teamPath) throws CheckmarxException; /** * Create team under given parentId * * @param parentTeamId * @param teamName * @return * @throws CheckmarxException */ public String createTeam(String parentTeamId, String teamName) throws CheckmarxException; /** * Get scan configuration Id * * @param configuration * @return * @throws CheckmarxException */ public Integer getScanConfiguration(String configuration) throws CheckmarxException; public Integer getPresetId(String preset) throws CheckmarxException; /** * Get scan summary for given scanId * * @param scanId * @return * @throws CheckmarxException */ public CxScanSummary getScanSummary(Integer scanId) throws CheckmarxException; public CxScanSummary getScanSummary(String projectId) throws CheckmarxException; public CxScanSummary getScanSummary(String teamName, String projectName) throws CheckmarxException; public Integer createScan(CxScanParams params, String comment) throws CheckmarxException; public CxXMLResultsType createScanAndReport(CxScanParams params, String comment) throws CheckmarxException; public ScanResults createScanAndReport(CxScanParams params, String comment, List filters) throws CheckmarxException; public CxXMLResultsType getLatestScanReport(String teamName, String projectName) throws CheckmarxException; public ScanResults getLatestScanResults(String teamName, String projectName, List filters) throws CheckmarxException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy