Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
MontiSecArc
Commits
8674cbeb
Commit
8674cbeb
authored
Oct 08, 2014
by
Paff
Browse files
analysis: derived roles for ports
parent
6469c4c5
Changes
7
Hide whitespace changes
Inline
Side-by-side
lang-example/mc.cfg
View file @
8674cbeb
/**
* Generated on
Tue
Oct 0
7
10:
34:17
CEST 2014
* Generated on
Wed
Oct 0
8
10:
07:44
CEST 2014
*/
config {
Require-Model:
...
...
montiSecArcAnalysis/mc.cfg
View file @
8674cbeb
/**
* Generated on
Tue
Oct 0
7
10:
34:35
CEST 2014
* Generated on
Wed
Oct 0
8
10:
08:12
CEST 2014
*/
config {
Require-Model:
...
...
montiSecArcAnalysis/src/main/java/secarc/error/MontiSecArcAnalysisErrorCodes.java
View file @
8674cbeb
...
...
@@ -88,6 +88,11 @@ public enum MontiSecArcAnalysisErrorCodes implements IErrorCode {
/**
* Trustlevel of encrypted path is higher than the environment
*/
TrustlevelPathHigherThanEnvironment
TrustlevelPathHigherThanEnvironment
,
/**
* Derives all roles for ports
*/
DerivedRolesPort
,
}
montiSecArcAnalysis/src/main/java/secarc/ets/analysis/role/DerivedRolesPort.java
0 → 100644
View file @
8674cbeb
package
secarc.ets.analysis.role
;
import
java.util.ArrayList
;
import
java.util.List
;
import
interfaces2.resolvers.AmbigousException
;
import
mc.IErrorCode
;
import
mc.umlp.arcd._ast.ASTArcPort
;
import
mc.umlp.arcd.ets.entries.ComponentEntry
;
import
mc.umlp.arcd.ets.entries.PortEntry
;
import
secarc.error.MontiSecArcAnalysisErrorCodes
;
import
secarc.ets.analysis.checker.Analysis
;
import
secarc.ets.analysis.checker.ISecAnalysisPortChecker
;
import
secarc.ets.check.MontiSecArcAnalysisConstants
;
import
secarc.ets.entries.RoleEntry
;
import
secarc.ets.entries.SecComponentEntry
;
import
secarc.ets.entries.SecPortEntry
;
import
secarc.ets.graph.ArchitectureGraph
;
public
class
DerivedRolesPort
extends
Analysis
implements
ISecAnalysisPortChecker
{
public
DerivedRolesPort
()
{
super
(
MontiSecArcAnalysisConstants
.
DERIVE_ROLES_PORT
);
}
@Override
public
void
check
(
ASTArcPort
node
,
SecPortEntry
entry
,
ArchitectureGraph
graph
)
throws
AmbigousException
{
List
<
RoleEntry
>
roles
=
new
ArrayList
<
RoleEntry
>();
SecComponentEntry
componentEntry
=
(
SecComponentEntry
)
resolver
.
resolve
(
node
.
getMainParent
().
getName
(),
ComponentEntry
.
KIND
,
getNameSpaceFor
(
node
.
getMainParent
()));
//Add all roles of the component
roles
.
addAll
(
componentEntry
.
getRoles
());
//Delete all roles of other ports
List
<
PortEntry
>
ports
=
componentEntry
.
getAllPorts
(
loader
,
deserializers
);
for
(
PortEntry
port
:
ports
)
{
if
(!
port
.
equals
(
entry
))
{
roles
.
removeAll
(((
SecPortEntry
)
port
).
getRoles
());
}
}
StringBuilder
sBuilder
=
new
StringBuilder
(
"The port "
+
entry
.
getName
()
+
" has the following roles: "
);
if
(
roles
.
size
()
>
0
)
{
sBuilder
.
append
(
roles
.
get
(
0
).
getName
());
roles
.
remove
(
0
);
}
else
{
return
;
}
for
(
RoleEntry
role
:
roles
)
{
sBuilder
.
append
(
", "
);
sBuilder
.
append
(
role
.
getName
());
}
addReport
(
sBuilder
.
toString
(),
node
.
get_SourcePositionStart
());
}
@Override
public
IErrorCode
getErrorCode
()
{
return
MontiSecArcAnalysisErrorCodes
.
DerivedRolesPort
;
}
}
montiSecArcAnalysis/src/main/java/secarc/ets/check/MontiSecArcAnalysisConstants.java
View file @
8674cbeb
...
...
@@ -58,6 +58,8 @@ public final class MontiSecArcAnalysisConstants {
public
static
final
String
DERIVED_ROLES_COMPONENT
=
"Derives all roles for components."
;
public
static
final
String
DERIVE_ROLES_PORT
=
"Derives all roles for ports."
;
public
static
final
String
ALL_IDENTITY
=
"Checks all analysis related to identity links."
;
public
static
final
String
IDENTITY_WITH_ENCRYPTION
=
"Checks if the communication between two components is encrypted when an identity link is used."
;
...
...
montiSecArcAnalysis/src/main/java/secarc/ets/check/MontiSecArcAnalysisCreator.java
View file @
8674cbeb
...
...
@@ -20,6 +20,7 @@ import secarc.ets.analysis.port.ListCriticalPorts;
import
secarc.ets.analysis.port.ListSystemIncomingPorts
;
import
secarc.ets.analysis.port.ListSystemOutgoingPorts
;
import
secarc.ets.analysis.role.DerivedRolesComponent
;
import
secarc.ets.analysis.role.DerivedRolesPort
;
import
secarc.ets.analysis.role.DerivedRolesThirdParty
;
...
...
@@ -154,6 +155,9 @@ public final class MontiSecArcAnalysisCreator {
//Derives roles for "normal " components
roleAnalysis
.
addChild
(
new
DerivedRolesComponent
());
//Derives roles for ports
roleAnalysis
.
addChild
(
new
DerivedRolesPort
());
//Analysis for identity
CompositeContextCondition
identityAnalysis
=
new
CompositeContextCondition
(
MontiSecArcAnalysisConstants
.
ALL_IDENTITY
);
...
...
montiSecArcAnalysis/src/test/java/secarc/MontiSecArcAnalysisTest.java
View file @
8674cbeb
...
...
@@ -117,8 +117,9 @@ public class MontiSecArcAnalysisTest extends TestWithSymtabAnalysis<MontiSecArcA
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
DerivedRolesComponent
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
TaintPropergation
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
IdentityWithEncryption
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
DerivedRolesPort
);
assertEquals
(
7
,
handler
.
getWarnings
().
size
());
assertEquals
(
8
,
handler
.
getWarnings
().
size
());
for
(
ProblemReport
error
:
handler
.
getErrors
())
{
assertTrue
(
errorCodes
.
contains
(
error
.
getErrorcode
()));
}
...
...
@@ -157,9 +158,10 @@ public class MontiSecArcAnalysisTest extends TestWithSymtabAnalysis<MontiSecArcA
List
<
MontiSecArcAnalysisErrorCodes
>
errorCodes
=
new
ArrayList
<
MontiSecArcAnalysisErrorCodes
>();
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
IdentityWithEncryption
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
DerivedRolesComponent
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
DerivedRolesPort
);
errorCodes
.
add
(
MontiSecArcAnalysisErrorCodes
.
TaintPropergation
);
assertEquals
(
8
,
handler
.
getWarnings
().
size
());
assertEquals
(
10
,
handler
.
getWarnings
().
size
());
for
(
ProblemReport
error
:
handler
.
getErrors
())
{
assertTrue
(
errorCodes
.
contains
(
error
.
getErrorcode
()));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment