Search in sources :

Example 16 with Model

use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.

the class VerdictLustreTranslatorTest method testUnmarshalFromLustre.

@Ignore
@Test
public void testUnmarshalFromLustre() throws IOException {
    File testFile = new File("src/test/resources/vdm-model.lus");
    Model testModel = VerdictLustreTranslator.unmarshalFromLustre(testFile);
    Model controlModel = VdmTest.createControlModel();
    Assertions.assertThat(testModel).usingRecursiveComparison().isEqualTo(controlModel);
}
Also used : Model(verdict.vdm.vdm_model.Model) File(java.io.File) Ignore(org.junit.Ignore) VdmTest(com.ge.verdict.vdm.VdmTest) Test(org.junit.Test)

Example 17 with Model

use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.

the class App method main.

public static void main(String[] args) throws URISyntaxException {
    // inputs
    if (args.length != 3) {
        File jarFile = new File(App.class.getProtectionDomain().getCodeSource().getLocation().toURI());
        LOGGER.error("Usage: java -jar {} <input file> <STEM output folder> <Soteria++ output folder>", jarFile.getName());
    } else {
        if (isValidXMLFile(args[0])) {
            if (isValidDir(args[1]) && isValidDir(args[2])) {
                File inputFile = new File(args[0]);
                // Translate VDM to Mbas inputs
                Model model = VDM2CSV.unmarshalFromXml(inputFile);
                VDM2CSV.marshalToMbasInputs(model, args[0], args[1], args[2]);
            }
        }
    }
}
Also used : Model(verdict.vdm.vdm_model.Model) File(java.io.File)

Example 18 with Model

use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.

the class App method main.

/*
    private static String[] enable_bm(String[] array) {
        String[] result = Arrays.copyOf(array, array.length + 1);
        result[array.length] = "-B";
        return result;
        }*/
public static void main(String[] args) throws IOException {
    Options options = createOptions();
    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    File inputFile = null;
    File outputFile = null;
    Model verdictDataModel = null;
    VDMInstrumentor threat_instrumentor = null;
    try {
        CommandLine cmdLine = parser.parse(options, args);
        // Load VDM model
        if (cmdLine.hasOption("i")) {
            String inputPath = cmdLine.getOptionValue("i");
            LOGGER.info(inputPath);
            inputFile = new File(inputPath);
            verdictDataModel = VdmTranslator.unmarshalFromXml(inputFile);
            threat_instrumentor = new VDMInstrumentor(verdictDataModel);
        }
        if (cmdLine.hasOption("o")) {
            String outputPath = cmdLine.getOptionValue("o");
            LOGGER.info(outputPath);
            outputFile = new File(outputPath);
            threat_instrumentor.instrument(verdictDataModel, cmdLine);
            // else {
            // LOGGER.info("Benign (Default)");
            // }
            VdmTranslator.marshalToXml(verdictDataModel, outputFile);
        }
    } catch (ParseException exp) {
        LOGGER.error("Error:");
        LOGGER.error(exp.getMessage());
        formatter.printHelp("VERDICT-Instrumentor", options);
        System.exit(-1);
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Model(verdict.vdm.vdm_model.Model) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 19 with Model

use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.

the class VerdictLustreTranslator method unmarshalFromLustre.

/**
 * Unmarshal a Verdict data model from a Lustre file.
 *
 * @param inputFile Lustre file to unmarshal from
 * @return Verdict data model from Lustre file
 */
public static Model unmarshalFromLustre(File inputFile) {
    // Parse the Lustre file into a parse tree
    LustreParser.ProgramContext programContext = VerdictLustreTranslator.parseFromLustre(inputFile);
    // Extract any data from the parse tree with our listener
    VerdictLustreListener extractor = new VerdictLustreListener(inputFile);
    ParseTreeWalker.DEFAULT.walk(extractor, programContext);
    // Return the model extracted from the parse tree
    Model model = extractor.getModel();
    return model;
}
Also used : Model(verdict.vdm.vdm_model.Model)

Example 20 with Model

use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.

the class MBASSynthesisHandler method runAadl2CsvWithSynthesis.

/**
 * Calls Aadl2Csv translator with synthesis enabled
 * @param dir
 * @param vdmFile
 * @param stemOutputDir
 * @param soteriaOutputDir
 */
public static void runAadl2CsvWithSynthesis(File dir, File vdmFile, String stemOutputDir, String soteriaOutputDir) {
    Agree2Vdm agree2vdm = new Agree2Vdm();
    Model model = agree2vdm.execute(dir);
    VdmTranslator.marshalToXml(model, vdmFile);
    Vdm2Csv vdm2csv = new Vdm2Csv(true);
    vdm2csv.execute(model, stemOutputDir, soteriaOutputDir, dir.getName());
}
Also used : Vdm2Csv(com.ge.research.osate.verdict.vdm2csv.Vdm2Csv) Model(verdict.vdm.vdm_model.Model) Agree2Vdm(com.ge.research.osate.verdict.aadl2vdm.Agree2Vdm)

Aggregations

Model (verdict.vdm.vdm_model.Model)31 File (java.io.File)18 Test (org.junit.Test)7 Agree2Vdm (com.ge.research.osate.verdict.aadl2vdm.Agree2Vdm)4 VdmTest (com.ge.verdict.vdm.VdmTest)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)4 Vdm2Csv (com.ge.research.osate.verdict.vdm2csv.Vdm2Csv)3 VDM2Lustre (edu.uiowa.clc.verdict.lustre.VDM2Lustre)3 CommandLine (org.apache.commons.cli.CommandLine)3 CostModel (com.ge.verdict.synthesis.CostModel)2 BlameAssignment (edu.uiowa.clc.verdict.blm.BlameAssignment)2 JAXBContext (jakarta.xml.bind.JAXBContext)2 JAXBException (jakarta.xml.bind.JAXBException)2 Aadl2Vdm (com.ge.research.osate.verdict.aadl2vdm.Aadl2Vdm)1 GSNInterface (com.ge.verdict.gsn.GSNInterface)1 SecurityGSNInterface (com.ge.verdict.gsn.SecurityGSNInterface)1 VerdictTestInstrumentor (com.ge.verdict.test.instrumentor.VerdictTestInstrumentor)1 Instrumentor (edu.uiowa.clc.verdict.crv.Instrumentor)1