Skip to content

Commit 6bea6ec

Browse files
committed
Added new Stereotype FeedbackData to the ML Top 10 profile + Input
Manipulation Check
1 parent 8a6b14d commit 6bea6ec

30 files changed

+3921
-98
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-23"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>carisma.check.mltop10checks</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.pde.PluginNature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
</natures>
28+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=23
3+
org.eclipse.jdt.core.compiler.compliance=23
4+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
5+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
8+
org.eclipse.jdt.core.compiler.release=enabled
9+
org.eclipse.jdt.core.compiler.source=23
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Mltop10checks
4+
Bundle-SymbolicName: carisma.check.mltop10checks;singleton:=true
5+
Bundle-Version: 1.0.0.qualifier
6+
Require-Bundle: org.eclipse.swt,
7+
org.eclipse.jface,
8+
carisma.modeltype.uml2,
9+
carisma.profile.umlsec,
10+
org.eclipse.uml2.uml,
11+
carisma.core,
12+
org.eclipse.ui,
13+
org.eclipse.core.runtime,
14+
org.eclipse.core.resources,
15+
org.eclipse.uml2.uml.resources,
16+
carisma.check.staticcheck,
17+
carisma.profile.umlsec.mltop10
18+
Automatic-Module-Name: carisma.check.mltop10checks
19+
Bundle-RequiredExecutionEnvironment: JavaSE-23
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.,\
5+
plugin.xml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?eclipse version="3.4"?>
3+
<plugin>
4+
<extension
5+
point="carisma.carismacheck">
6+
<check
7+
description="Performs input manipulation check"
8+
id="carisma.check.mltop10checks.inputmanipulation"
9+
implementingClass="carisma.check.mltop10checks.inputmanipulation.InputManipulationCheck"
10+
name="MLTop10 Input Manipulation Check"
11+
publisher="Alexander Peikert"
12+
targetModelType="UML2">
13+
</check>
14+
</extension>
15+
16+
</plugin>
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package carisma.check.mltop10checks.inputmanipulation;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.Map;
6+
7+
import org.eclipse.emf.ecore.resource.Resource;
8+
import org.eclipse.uml2.uml.Artifact;
9+
import org.eclipse.uml2.uml.Package;
10+
11+
import carisma.core.analysis.AnalysisHost;
12+
import carisma.core.analysis.DummyHost;
13+
import carisma.core.analysis.result.AnalysisResultMessage;
14+
import carisma.core.analysis.result.StatusType;
15+
import carisma.core.checks.CarismaCheckWithID;
16+
import carisma.core.checks.CheckParameter;
17+
import carisma.modeltype.uml2.UMLHelper;
18+
import carisma.profile.umlsec.mltop10.MLTop10;
19+
import carisma.profile.umlsec.mltop10.MLTop10Util;
20+
21+
/**
22+
* analyzes an deployment diagram with respect to input manipulation rules.
23+
*
24+
* @author Alexander Peikert
25+
*
26+
*/
27+
28+
public class InputManipulationCheck implements CarismaCheckWithID {
29+
30+
public static final String CHECK_ID = "carisma.check.mltop10checks.inputmanipulation";
31+
public static final String CHECK_NAME = "MLTop10 Input Manipulation Check";
32+
33+
/**
34+
* the model to check.
35+
*/
36+
private Package model = null;
37+
38+
/**
39+
* AnalysisHost for report.
40+
*/
41+
private AnalysisHost analysisHost;
42+
private ArrayList<Artifact> aiapplicationList;
43+
private ArrayList<Artifact> mlmodelList;
44+
45+
public InputManipulationCheck() {
46+
// TODO Auto-generated constructor stub
47+
}
48+
49+
@Override
50+
public final boolean perform(final Map<String, CheckParameter> parameters, final AnalysisHost newHost) {
51+
if (newHost != null) {
52+
this.analysisHost = newHost;
53+
} else {
54+
this.analysisHost = new DummyHost(true);
55+
}
56+
Resource currentModel = this.analysisHost.getAnalyzedModel();
57+
if (currentModel.getContents().isEmpty()) {
58+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.WARNING, "Empty model"));
59+
this.analysisHost.appendLineToReport("Empty model");
60+
return false;
61+
}
62+
if (currentModel.getContents().get(0) instanceof Package) {
63+
this.model = (Package) currentModel.getContents().get(0);
64+
return startCheck();
65+
}
66+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.WARNING, "Content is not a model!"));
67+
this.analysisHost.appendLineToReport("Content is not a model!");
68+
return false;
69+
}
70+
71+
/**
72+
* main function that starts the check.
73+
*
74+
* @return true if the model is correct according to data access control rules,
75+
* false otherwise
76+
*/
77+
78+
public boolean startCheck() {
79+
80+
boolean checkSuccessful = true;
81+
boolean warningPotentialAttack = false;
82+
int numMlModels = 0;
83+
int numApplication = 0;
84+
85+
ArrayList<Artifact> artifactList = (ArrayList<Artifact>) UMLHelper.getAllElementsOfType(model, Artifact.class);
86+
ArrayList<Artifact> mlmodelList = new ArrayList<Artifact>();
87+
ArrayList<Artifact> aiapplicationList = new ArrayList<Artifact>();
88+
89+
// ----------------------------------------------------------------------------------------------
90+
// Check if there are more / less than one ML Model and AI Application
91+
92+
for (int i = 0; i < artifactList.size(); i++) {
93+
if (MLTop10Util.hasStereotype(artifactList.get(i), MLTop10.MLModel)) {
94+
numMlModels++;
95+
mlmodelList.add(artifactList.get(i));
96+
97+
}
98+
if (MLTop10Util.hasStereotype(artifactList.get(i), MLTop10.AIApplication)) {
99+
numApplication++;
100+
aiapplicationList.add(artifactList.get(i));
101+
102+
}
103+
104+
}
105+
if (numMlModels < 1 || numApplication < 1) {
106+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.INFO,
107+
"Your model does not contain a ML Model or AI Application"));
108+
return checkSuccessful;
109+
} else if (numMlModels > 1 || numApplication > 1) {
110+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.INFO,
111+
"Your model contains more than one ML Model or AI Application"));
112+
checkSuccessful = false;
113+
return checkSuccessful;
114+
} else {
115+
this.analysisHost.addResultMessage(
116+
new AnalysisResultMessage(StatusType.INFO, "Your model contains a ML Model and an AI Application"));
117+
Artifact mlmodel = mlmodelList.get(0);
118+
List<Object> taggedValueAdversialTraining = null;
119+
List<Object> taggedValueDefenseMechanism = null;
120+
taggedValueAdversialTraining = MLTop10Util.getTaggedValues("AdversarialTraining", MLTop10.MLModel, mlmodel);
121+
taggedValueDefenseMechanism = MLTop10Util.getTaggedValues("DefenseMechanism", MLTop10.MLModel, mlmodel);
122+
123+
if (taggedValueAdversialTraining.get(0).toString() == "false") {
124+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.WARNING,
125+
"Your model ML Model is not secured against adversarial training"));
126+
warningPotentialAttack = true;
127+
128+
}
129+
if (taggedValueDefenseMechanism.get(0).toString() == "false") {
130+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.WARNING,
131+
"Your model ML Model has no robust defense mechanism against manipulative attacks"));
132+
warningPotentialAttack = true;
133+
}
134+
135+
Artifact aiapplication = aiapplicationList.get(0);
136+
List<Object> taggedValueInputValidation = null;
137+
taggedValueInputValidation = MLTop10Util.getTaggedValues("InputValidation", MLTop10.AIApplication,
138+
aiapplication);
139+
140+
if (taggedValueInputValidation.get(0).toString() == "false") {
141+
this.analysisHost.addResultMessage(new AnalysisResultMessage(StatusType.WARNING,
142+
"Your model AI Application does not perform input validation"));
143+
warningPotentialAttack = true;
144+
}
145+
146+
if (warningPotentialAttack == true) {
147+
this.analysisHost.addResultMessage(
148+
new AnalysisResultMessage(StatusType.WARNING, "An Input Mainpulation Attack is possible!"));
149+
}
150+
151+
}
152+
return checkSuccessful;
153+
154+
}
155+
156+
@Override
157+
public String getCheckID() {
158+
// TODO Auto-generated method stub
159+
return null;
160+
}
161+
162+
@Override
163+
public String getName() {
164+
// TODO Auto-generated method stub
165+
return null;
166+
}
167+
168+
}

plugins/carisma.profile.umlsec.mltop10/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Bundle-ClassPath: .
88
Bundle-Vendor: %providerName
99
Bundle-Localization: plugin
1010
Bundle-RequiredExecutionEnvironment: JavaSE-17
11-
Export-Package: mltop10,
11+
Export-Package: carisma.profile.umlsec.mltop10,
12+
mltop10,
1213
mltop10.impl,
1314
mltop10.util
1415
Require-Bundle: org.eclipse.core.runtime,

plugins/carisma.profile.umlsec.mltop10/gen-src/mltop10/AIApplication.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* <ul>
1818
* <li>{@link mltop10.AIApplication#getBase_Artifact <em>Base Artifact</em>}</li>
1919
* <li>{@link mltop10.AIApplication#isInputValidation <em>Input Validation</em>}</li>
20+
* <li>{@link mltop10.AIApplication#isCheckModelResultAuthenticity <em>Check Model Result Authenticity</em>}</li>
21+
* <li>{@link mltop10.AIApplication#isTamperEvidentLogging <em>Tamper Evident Logging</em>}</li>
2022
* </ul>
2123
*
2224
* @see mltop10.Mltop10Package#getAIApplication()
@@ -76,4 +78,56 @@ public interface AIApplication extends EObject {
7678
*/
7779
void setInputValidation(boolean value);
7880

81+
/**
82+
* Returns the value of the '<em><b>Check Model Result Authenticity</b></em>' attribute.
83+
* <!-- begin-user-doc -->
84+
* <p>
85+
* If the meaning of the '<em>Check Model Result Authenticity</em>' attribute isn't clear,
86+
* there really should be more of a description here...
87+
* </p>
88+
* <!-- end-user-doc -->
89+
* @return the value of the '<em>Check Model Result Authenticity</em>' attribute.
90+
* @see #setCheckModelResultAuthenticity(boolean)
91+
* @see mltop10.Mltop10Package#getAIApplication_CheckModelResultAuthenticity()
92+
* @model dataType="org.eclipse.uml2.types.Boolean" required="true" ordered="false"
93+
* @generated
94+
*/
95+
boolean isCheckModelResultAuthenticity();
96+
97+
/**
98+
* Sets the value of the '{@link mltop10.AIApplication#isCheckModelResultAuthenticity <em>Check Model Result Authenticity</em>}' attribute.
99+
* <!-- begin-user-doc -->
100+
* <!-- end-user-doc -->
101+
* @param value the new value of the '<em>Check Model Result Authenticity</em>' attribute.
102+
* @see #isCheckModelResultAuthenticity()
103+
* @generated
104+
*/
105+
void setCheckModelResultAuthenticity(boolean value);
106+
107+
/**
108+
* Returns the value of the '<em><b>Tamper Evident Logging</b></em>' attribute.
109+
* <!-- begin-user-doc -->
110+
* <p>
111+
* If the meaning of the '<em>Tamper Evident Logging</em>' attribute isn't clear,
112+
* there really should be more of a description here...
113+
* </p>
114+
* <!-- end-user-doc -->
115+
* @return the value of the '<em>Tamper Evident Logging</em>' attribute.
116+
* @see #setTamperEvidentLogging(boolean)
117+
* @see mltop10.Mltop10Package#getAIApplication_TamperEvidentLogging()
118+
* @model dataType="org.eclipse.uml2.types.Boolean" required="true" ordered="false"
119+
* @generated
120+
*/
121+
boolean isTamperEvidentLogging();
122+
123+
/**
124+
* Sets the value of the '{@link mltop10.AIApplication#isTamperEvidentLogging <em>Tamper Evident Logging</em>}' attribute.
125+
* <!-- begin-user-doc -->
126+
* <!-- end-user-doc -->
127+
* @param value the new value of the '<em>Tamper Evident Logging</em>' attribute.
128+
* @see #isTamperEvidentLogging()
129+
* @generated
130+
*/
131+
void setTamperEvidentLogging(boolean value);
132+
79133
} // AIApplication

0 commit comments

Comments
 (0)