Search in sources :

Example 1 with Model

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

the class VDMInstrumentor method instrument.

public Model instrument(Model vdm_model, List<String> threats, boolean blameAssignment, boolean componentLevel) {
    Model instrumented_model = null;
    retrieve_component_and_channels(vdm_model, threats, blameAssignment, componentLevel);
    return instrumented_model;
}
Also used : Model(verdict.vdm.vdm_model.Model)

Example 2 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 {
    if (args.length != 2) {
        File jarFile = new File(App.class.getProtectionDomain().getCodeSource().getLocation().toURI());
        LOGGER.error("Usage: java -jar {} <input file> <output file>", jarFile.getName());
    } else {
        // Get the input file
        File inputFile = new File(args[0]);
        File outputFile = new File(args[1]);
        Model vdmModel = VdmTranslator.unmarshalFromXml(inputFile);
        VerdictTestInstrumentor atg = new VerdictTestInstrumentor(vdmModel);
        atg.instrumentTests();
        VdmTranslator.marshalToXml(vdmModel, outputFile);
    }
}
Also used : Model(verdict.vdm.vdm_model.Model) File(java.io.File)

Example 3 with Model

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

the class GSNHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    if (VerdictHandlersUtils.startRun()) {
        // Print on console
        VerdictHandlersUtils.setPrintOnConsole("");
        IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
        PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
        VerdictHandlersUtils.printGreeting();
        Thread createGsnThread = new Thread() {

            @Override
            public void run() {
                try {
                    // Getting project directory
                    List<String> selection = VerdictHandlersUtils.getCurrentSelection(event);
                    File projectDir = new File(selection.get(0));
                    /**
                     * Create the xml model for the GSN creator
                     * in the GSN output directory as modelXML.xml
                     */
                    Aadl2Vdm translatorObject = new Aadl2Vdm();
                    Model model = translatorObject.execute(projectDir);
                    // //For testing aadl2vdm translator
                    // File modelXml = new File("", "TestModel.xml");
                    // VdmTranslator.marshalToXml(model, modelXml);
                    // getting required input
                    String userInput = decideCorrectInput(model);
                    // Checking if all necessary settings exist
                    String stemProjPath = BundlePreferences.getStemDir();
                    if (stemProjPath.isEmpty()) {
                        System.out.println("Please set STEM directory path in Preferences");
                        return;
                    }
                    String dockerImage = BundlePreferences.getDockerImage();
                    String bundleJar = BundlePreferences.getBundleJar();
                    if (dockerImage.isEmpty() && bundleJar.isEmpty()) {
                        System.out.println("Please set VERDICT Bundle Jar path in Preferences");
                        return;
                    }
                    String soteriaPpBin = BundlePreferences.getSoteriaPpBin();
                    if (dockerImage.isEmpty() && soteriaPpBin.isEmpty()) {
                        System.out.println("Please set soteria++ binary path in Preferences");
                        return;
                    }
                    String graphVizPath = BundlePreferences.getGraphVizPath();
                    if (dockerImage.isEmpty() && graphVizPath.isEmpty()) {
                        System.out.println("Please set GraphViz path in Preferences");
                        return;
                    }
                    // Create CSVData, Output, Graphs, GSN folders if they don't exist
                    // If they exist, delete all unnecessary files
                    File dataFolder = new File(stemProjPath, "CSVData");
                    File outputFolder = new File(stemProjPath, "Output");
                    File graphsFolder = new File(stemProjPath, "Graphs");
                    File gsnOutputFolder = new File(stemProjPath, "gsn");
                    if (dataFolder.exists() && dataFolder.isDirectory()) {
                        deleteFilesInDir("csv", dataFolder);
                    } else {
                        dataFolder.mkdir();
                    }
                    if (outputFolder.exists() && outputFolder.isDirectory()) {
                        deleteFilesInDir("csv", outputFolder);
                    } else {
                        outputFolder.mkdir();
                    }
                    if (graphsFolder.exists() && graphsFolder.isDirectory()) {
                        deleteFilesInDir("svg", graphsFolder);
                    } else {
                        graphsFolder.mkdir();
                    }
                    if (gsnOutputFolder.exists() && gsnOutputFolder.isDirectory()) {
                        deleteFilesInDir("svg", gsnOutputFolder);
                        deleteFilesInDir("dot", gsnOutputFolder);
                        deleteFilesInDir("xml", gsnOutputFolder);
                    } else {
                        gsnOutputFolder.mkdir();
                    }
                    // translating AADL to CSV first to create the soteria++ outputs
                    runAadl2Csv(projectDir, dataFolder.getAbsolutePath(), outputFolder.getAbsolutePath());
                    // running MBAS
                    boolean outputsGenerated = runBundleMBAS(bundleJar, dockerImage, projectDir.getName(), stemProjPath, soteriaPpBin, graphVizPath);
                    // if MBAS succeeded, proceed to GSN
                    if (outputsGenerated) {
                        /**
                         * The GSN creator backend needs:
                         * 	1. The rootId
                         *  2. The Gsn output directory
                         *  3. The Soteria++ Output directory
                         *  4. The path of the project directory
                         *     which contains the aadl files with CASE properties
                         */
                        String rootId = userInput;
                        String soteriaOutputDir = stemProjPath + SEP + "Output" + SEP + "Soteria_Output";
                        String gsnOutputDir = gsnOutputFolder.getCanonicalPath();
                        String modelAadlDir = projectDir.getCanonicalPath();
                        /**
                         * save the xml model for the GSN creator
                         * in the GSN output directory as modelXML.xml
                         */
                        File modelXml = new File(gsnOutputFolder, "modelXML.xml");
                        VdmTranslator.marshalToXml(model, modelXml);
                        // send the arguments to the backend
                        if (runBundle(bundleJar, dockerImage, rootId, gsnOutputDir, soteriaOutputDir, modelAadlDir, projectDir.getName(), graphVizPath)) {
                            // Show graphs in tab if option selected
                            if (AssuranceCaseSettingsPanel.showInTab) {
                                // Open SVG GSN files
                                VerdictHandlersUtils.openSvgGraphsInDir(new File(stemProjPath, "gsn").getAbsolutePath());
                            }
                        }
                    }
                } catch (IOException e) {
                    VerdictLogger.severe(e.toString());
                } finally {
                    VerdictHandlersUtils.finishRun();
                }
            }
        };
        createGsnThread.start();
    }
    return null;
}
Also used : Aadl2Vdm(com.ge.research.osate.verdict.aadl2vdm.Aadl2Vdm) IIntroPart(org.eclipse.ui.intro.IIntroPart) Model(verdict.vdm.vdm_model.Model) IOException(java.io.IOException) File(java.io.File)

Example 4 with Model

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

the class GSNHandler method runAadl2Csv.

/**
 * Calls Aadl2Csv translator
 * @param dir
 * @param stemOutputDir
 * @param soteriaOutputDir
 */
public static void runAadl2Csv(File dir, String stemOutputDir, String soteriaOutputDir) {
    Agree2Vdm agree2vdm = new Agree2Vdm();
    Model model = agree2vdm.execute(dir);
    Vdm2Csv vdm2csv = new Vdm2Csv();
    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)

Example 5 with Model

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

the class Aadl2Vdm method execute.

/**
 * The execute() method
 * creates a new Model object and
 * returns it
 *
 * @param inputDir a reference to a directory
 */
public Model execute(File inputDir) {
    logHeader("AADL2VDM");
    Model m = new Model();
    Agree2Vdm agree2vdm = new Agree2Vdm();
    // first argument in the function call returns list of objects from all AADL files in the project including
    // imported files - this is needed to resolve issue of missing cross references to types defined in imported files
    // second argument returns the list of objects from only AADL files in the project - only these
    // objects are used while populating the VDM
    m = populateVDMFromAadlObjects(agree2vdm.preprocessAadlFiles(inputDir), preprocessAadlFiles(inputDir), m);
    System.out.println("Info: Created VDM object");
    return m;
}
Also used : Model(verdict.vdm.vdm_model.Model)

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