Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mihai.herda
keyjoana
Commits
593fe1a9
Commit
593fe1a9
authored
Nov 22, 2019
by
Joachim Müssig
Browse files
clear up code, javadoc
parent
16bd0497
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/joanakey/slicing/BranchAnalyzer.java
View file @
593fe1a9
...
...
@@ -32,7 +32,7 @@ import edu.kit.joana.ifc.sdg.graph.SDGNode;
* based on the Wala CFG whether the (potential) illegal information
* flow described by the chop can only occur along the true branch or
* only along the false branch or both.
* @author mihai
* @author mihai
, joachim
*/
public
class
BranchAnalyzer
{
...
...
@@ -112,9 +112,6 @@ public class BranchAnalyzer {
}
return
result
;
}
...
...
@@ -267,7 +264,6 @@ public class BranchAnalyzer {
ISSABasicBlock
falseBlock
=
Util
.
getNotTakenSuccessor
(
cfg
,
basicblock
);
//construct the set of successor basic blocks along the true branch
Collection
<
ISSABasicBlock
>
trueSuccessors
=
cfg
.
getNormalSuccessors
(
trueBlock
);
System
.
out
.
println
(
cfg
.
getSuccNodeCount
(
falseBlock
));
trueSuccessors
.
add
(
trueBlock
);
//construct the set of successor basic blocks along the false branch
Collection
<
ISSABasicBlock
>
falseSuccessors
=
cfg
.
getNormalSuccessors
(
falseBlock
);
...
...
@@ -289,11 +285,10 @@ public class BranchAnalyzer {
//get basic block for successor
SSACFG
succCFG
=
getCFG
(
succ
);
BasicBlock
succBlock
=
succCFG
.
getBlockForInstruction
(
succInstrIndex
);
List
<
ISSABasicBlock
>
dominators
=
calculateDominators
(
succBlock
,
cfg
);
if
(
inFalseBranch
(
dominators
,
falseBlock
))
{
//TODO: remove if not needed
}
//set flag if the successor is among the true successors
...
...
@@ -353,7 +348,6 @@ public class BranchAnalyzer {
}
}
//TODO:
private
boolean
inTrueBranch
(
List
<
ISSABasicBlock
>
dominators
,
ISSABasicBlock
firstTrueBlock
)
{
//return true if first true block of predicate block is contained in dominators
if
(
dominators
.
contains
(
firstTrueBlock
))
{
...
...
@@ -439,6 +433,11 @@ public class BranchAnalyzer {
}
return
result
;
}
/**
* generate the contact and the assume method. This string should be appended to the sliced java file.
* @return String with assume contract and assume method
*/
public
String
getAssumeMethod
()
{
String
contract
=
"/*@\n"
+
"@ requires true;\n"
...
...
src/joanakey/slicing/Main.java
View file @
593fe1a9
...
...
@@ -39,12 +39,10 @@ public class Main {
// File joakFile = new File("/home/mihai/workspace/keyjoana/testdata/loop2.joak");
File
joakFile
=
new
File
(
"/home/joachim/JoanaKeYBeispiele/SecureExamples/IFLoop2/program/Joak/test.joak"
);
// File joakFile = new File("/home/joachim/JoanaKeYBeispiele/SecureExamples/IFLoop2/program/Joak/IFLoop2JoakWithSDGNodesWithStateSaverString3.joak");
System
.
out
.
println
(
"Starting Joana..."
);
JoanaAndKeYCheckData
data
=
CombinedApproach
.
parseInputFile
(
joakFile
);
data
.
addAnnotations
();
//IFCAnalysis ana = data.getAnalysis();
SDGAnalysis
ana
=
(
SDGAnalysis
)
data
.
getAnalysis
();
...
...
@@ -86,7 +84,6 @@ public class Main {
cg
=
data
.
getStateSaver
().
getCallGraph
();
//TODO: PreProcessor
ProgramSimplifier
simplifer
=
new
ProgramSimplifier
(
high
,
low
,
sdg
);
//Set<SDGNode> relevantNodes = simplifer.getBackwardsSlice();
// Set<SDGNode> relevantNodes = simplifer.getChopNodes();
...
...
src/joanakey/slicing/SourceCodeSlicer.java
View file @
593fe1a9
...
...
@@ -235,6 +235,12 @@ public class SourceCodeSlicer {
}
/**
* Write the slice to a File
* @param slice result you want to write to a file
* @param target path to the File
* @throws IOException
*/
public
void
writeSlice
(
Map
<
String
,
Set
<
Integer
>>
slice
,
String
target
)
throws
IOException
{
File
sourceFolder
=
new
File
(
pathToJavaSource
);
...
...
@@ -277,6 +283,10 @@ public class SourceCodeSlicer {
}
}
/**
* print the slice result
* @param slice
*/
public
void
printSlice
(
Map
<
String
,
Set
<
Integer
>>
slice
){
for
(
String
file
:
slice
.
keySet
()){
...
...
src/joanakey/slicing/ViolationSlicer.java
View file @
593fe1a9
...
...
@@ -50,7 +50,6 @@ public class ViolationSlicer {
File
target
=
new
File
(
pathToJavaFile
);
String
targetPath
=
target
.
getParentFile
().
getAbsolutePath
()
+
File
.
separator
+
"slices"
+
File
.
separator
+
"slice"
+
"Source"
+
high
+
"Sink"
+
low
+
File
.
separator
+
"src"
;
System
.
out
.
println
(
"Writing slice to: "
+
targetPath
);
try
{
slicer
.
writeSlice
(
slice
,
targetPath
);
...
...
@@ -103,6 +102,7 @@ public class ViolationSlicer {
//TODO: finish
//warning not finished yet
@Deprecated
public
static
void
simpifyProgramForAllViolations
(
Collection
<?
extends
IViolation
<
SecurityNode
>>
violations
,
SDG
sdg
,
JoanaAndKeYCheckData
checkData
)
{
int
i
=
1
;
for
(
IViolation
<
SecurityNode
>
violation
:
violations
)
{
...
...
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