function validateSarifFileSchema(sarifFilePath) {
    if (fs.lstatSync(sarifFilePath).isDirectory()) {
        return true;
    }
    const sarif = JSON.parse(fs.readFileSync(sarifFilePath, 'utf8'));
    const schema = JSON.parse(fs.readFileSync(__dirname + '/../src/sarif_v2.1.0_schema.json', 'utf8'));
    const result = new jsonschema.Validator().validate(sarif, schema);
    if (result.valid) {
        return true;
    }
    else {
        // Set the failure message to the stacks of all the errors.
        // This should be of a manageable size and may even give enough to fix the error.
        const errorMessages = result.errors.map(e => "- " + e.stack);
        core.setFailed("Unable to upload \"" + sarifFilePath + "\" as it is not valid SARIF:\n" + errorMessages.join("\n"));
        // Also output the more verbose error messages in groups as these may be very large.
        for (const error of result.errors) {
            core.startGroup("Error details: " + error.stack);
            core.info(JSON.stringify(error, null, 2));
            core.endGroup();
        }
        return false;
    }
}
// otherwise returns the empty list if the file is valid.
otherwise returns the empty list if the file is valid.
otherwise returns the empty list if the file is valid .
function validateSarifFileSchema(sarifFilePath) {
    if (fs.lstatSync(sarifFilePath).isDirectory()) {
        return true;
    }
    const sarif = JSON.parse(fs.readFileSync(sarifFilePath, 'utf8'));
    const schema = JSON.parse(fs.readFileSync(__dirname + '/../src/sarif_v2.1.0_schema.json', 'utf8'));
    const result = new jsonschema.Validator().validate(sarif, schema);
    if (result.valid) {
        return true;
    }
    else {
        const errorMessages = result.errors.map(e => "- " + e.stack);
        core.setFailed("Unable to upload \"" + sarifFilePath + "\" as it is not valid SARIF:\n" + errorMessages.join("\n"));
        for (const error of result.errors) {
            core.startGroup("Error details: " + error.stack);
            core.info(JSON.stringify(error, null, 2));
            core.endGroup();
        }
        return false;
    }
}
function validateSarifFileSchema ( sarifFilePath ) { if ( fs . lstatSync ( sarifFilePath ) . isDirectory ( ) ) { return true ; } const sarif = JSON . parse ( fs . readFileSync ( sarifFilePath , 'utf8' ) ) ; const schema = JSON . parse ( fs . readFileSync ( __dirname + '/../src/sarif_v2.1.0_schema.json' , 'utf8' ) ) ; const result = new jsonschema . Validator ( ) . validate ( sarif , schema ) ; if ( result . valid ) { return true ; } else { const errorMessages = result . errors . map ( e => "- " + e . stack ) ; core . setFailed ( "Unable to upload \"" + sarifFilePath + "\" as it is not valid SARIF:\n" + errorMessages . join ( "\n" ) ) ; for ( const error of result . errors ) { core . startGroup ( "Error details: " + error . stack ) ; core . info ( JSON . stringify ( error , null , 2 ) ) ; core . endGroup ( ) ; } return false ; } }
otherwise returns the empty list if the file is valid.
otherwise returns the empty list if the file is valid .
// Set the failure message to the stacks of all the errors. // This should be of a manageable size and may even give enough to fix the error. // Also output the more verbose error messages in groups as these may be very large.