async function uploadFiles(sarifFiles) {
    core.startGroup("Uploading results");
    core.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
    const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
    if (process.env[sentinelEnvVar]) {
        core.error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
        return false;
    }
    core.exportVariable(sentinelEnvVar, sentinelEnvVar);
    // Validate that the files we were asked to upload are all valid SARIF files
    for (const file of sarifFiles) {
        if (!validateSarifFileSchema(file)) {
            return false;
        }
    }
    const commitOid = await util.getCommitOid();
    const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID');
    const ref = util.getRef();
    const analysisKey = await util.getAnalysisKey();
    const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW');
    const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT];
    let sarifPayload = combineSarifFiles(sarifFiles);
    sarifPayload = fingerprints.addFingerprints(sarifPayload);
    const zipped_sarif = zlib_1.default.gzipSync(sarifPayload).toString('base64');
    let checkoutPath = core.getInput('checkout_path');
    let checkoutURI = file_url_1.default(checkoutPath);
    const workflowRunID = parseInt(workflowRunIDStr, 10);
    if (Number.isNaN(workflowRunID)) {
        core.setFailed('GITHUB_RUN_ID must define a non NaN workflow run ID');
        return false;
    }
    let matrix = core.getInput('matrix');
    if (matrix === "null" || matrix === "") {
        matrix = undefined;
    }
    const toolNames = util.getToolNames(sarifPayload);
    const payload = JSON.stringify({
        "commit_oid": commitOid,
        "ref": ref,
        "analysis_key": analysisKey,
        "analysis_name": analysisName,
        "sarif": zipped_sarif,
        "workflow_run_id": workflowRunID,
        "checkout_uri": checkoutURI,
        "environment": matrix,
        "started_at": startedAt,
        "tool_names": toolNames,
    });
    // Log some useful debug info about the info
    core.debug("Raw upload size: " + sarifPayload.length + " bytes");
    core.debug("Base64 zipped upload size: " + zipped_sarif.length + " bytes");
    core.debug("Number of results in upload: " + countResultsInSarif(sarifPayload));
    // Make the upload
    const succeeded = await uploadPayload(payload);
    core.endGroup();
    return succeeded;
}
// Returns true iff the upload occurred and succeeded
Returns true iff the upload occurred and succeeded
Returns true iff the upload occurred and succeeded
async function uploadFiles(sarifFiles) {
    core.startGroup("Uploading results");
    core.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
    const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
    if (process.env[sentinelEnvVar]) {
        core.error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
        return false;
    }
    core.exportVariable(sentinelEnvVar, sentinelEnvVar);
    for (const file of sarifFiles) {
        if (!validateSarifFileSchema(file)) {
            return false;
        }
    }
    const commitOid = await util.getCommitOid();
    const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID');
    const ref = util.getRef();
    const analysisKey = await util.getAnalysisKey();
    const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW');
    const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT];
    let sarifPayload = combineSarifFiles(sarifFiles);
    sarifPayload = fingerprints.addFingerprints(sarifPayload);
    const zipped_sarif = zlib_1.default.gzipSync(sarifPayload).toString('base64');
    let checkoutPath = core.getInput('checkout_path');
    let checkoutURI = file_url_1.default(checkoutPath);
    const workflowRunID = parseInt(workflowRunIDStr, 10);
    if (Number.isNaN(workflowRunID)) {
        core.setFailed('GITHUB_RUN_ID must define a non NaN workflow run ID');
        return false;
    }
    let matrix = core.getInput('matrix');
    if (matrix === "null" || matrix === "") {
        matrix = undefined;
    }
    const toolNames = util.getToolNames(sarifPayload);
    const payload = JSON.stringify({
        "commit_oid": commitOid,
        "ref": ref,
        "analysis_key": analysisKey,
        "analysis_name": analysisName,
        "sarif": zipped_sarif,
        "workflow_run_id": workflowRunID,
        "checkout_uri": checkoutURI,
        "environment": matrix,
        "started_at": startedAt,
        "tool_names": toolNames,
    });
    core.debug("Raw upload size: " + sarifPayload.length + " bytes");
    core.debug("Base64 zipped upload size: " + zipped_sarif.length + " bytes");
    core.debug("Number of results in upload: " + countResultsInSarif(sarifPayload));
    const succeeded = await uploadPayload(payload);
    core.endGroup();
    return succeeded;
}
async function uploadFiles ( sarifFiles ) { core . startGroup ( "Uploading results" ) ; core . info ( "Uploading sarif files: " + JSON . stringify ( sarifFiles ) ) ; const sentinelEnvVar = "CODEQL_UPLOAD_SARIF" ; if ( process . env [ sentinelEnvVar ] ) { core . error ( "Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job" ) ; return false ; } core . exportVariable ( sentinelEnvVar , sentinelEnvVar ) ; for ( const file of sarifFiles ) { if ( ! validateSarifFileSchema ( file ) ) { return false ; } } const commitOid = await util . getCommitOid ( ) ; const workflowRunIDStr = util . getRequiredEnvParam ( 'GITHUB_RUN_ID' ) ; const ref = util . getRef ( ) ; const analysisKey = await util . getAnalysisKey ( ) ; const analysisName = util . getRequiredEnvParam ( 'GITHUB_WORKFLOW' ) ; const startedAt = process . env [ sharedEnv . CODEQL_ACTION_STARTED_AT ] ; let sarifPayload = combineSarifFiles ( sarifFiles ) ; sarifPayload = fingerprints . addFingerprints ( sarifPayload ) ; const zipped_sarif = zlib_1 . default . gzipSync ( sarifPayload ) . toString ( 'base64' ) ; let checkoutPath = core . getInput ( 'checkout_path' ) ; let checkoutURI = file_url_1 . default ( checkoutPath ) ; const workflowRunID = parseInt ( workflowRunIDStr , 10 ) ; if ( Number . isNaN ( workflowRunID ) ) { core . setFailed ( 'GITHUB_RUN_ID must define a non NaN workflow run ID' ) ; return false ; } let matrix = core . getInput ( 'matrix' ) ; if ( matrix === "null" || matrix === "" ) { matrix = undefined ; } const toolNames = util . getToolNames ( sarifPayload ) ; const payload = JSON . stringify ( { "commit_oid" : commitOid , "ref" : ref , "analysis_key" : analysisKey , "analysis_name" : analysisName , "sarif" : zipped_sarif , "workflow_run_id" : workflowRunID , "checkout_uri" : checkoutURI , "environment" : matrix , "started_at" : startedAt , "tool_names" : toolNames , } ) ; core . debug ( "Raw upload size: " + sarifPayload . length + " bytes" ) ; core . debug ( "Base64 zipped upload size: " + zipped_sarif . length + " bytes" ) ; core . debug ( "Number of results in upload: " + countResultsInSarif ( sarifPayload ) ) ; const succeeded = await uploadPayload ( payload ) ; core . endGroup ( ) ; return succeeded ; }
Returns true iff the upload occurred and succeeded
Returns true iff the upload occurred and succeeded
// Validate that the files we were asked to upload are all valid SARIF files // Log some useful debug info about the info // Make the upload