Skip to content

Commit

Permalink
Adding HardCodedError type
Browse files Browse the repository at this point in the history
  • Loading branch information
johspaeth committed May 14, 2019
1 parent 9ed612a commit a1b85ba
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CryptoAnalysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<artifactItem>
<groupId>de.fraunhofer.iem</groupId>
<artifactId>BouncyCastle</artifactId>
<version>0.4-SNAPSHOT</version>
<version>0.4</version>
<classifier>ruleset</classifier>
<type>zip</type>
<overWrite>true</overWrite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public interface ErrorVisitor {
public void visit(ImpreciseValueExtractionError predicateError);
public void visit(NeverTypeOfError predicateError);
public void visit(PredicateContradictionError predicateContradictionError);
public void visit(HardCodedError hardcodedError);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package crypto.analysis.errors;

import crypto.analysis.IAnalysisSeed;
import crypto.extractparameter.CallSiteWithExtractedValue;
import crypto.interfaces.ISLConstraint;
import crypto.rules.CryptSLRule;

public class HardCodedError extends ConstraintError {

public HardCodedError(CallSiteWithExtractedValue cs, CryptSLRule rule, IAnalysisSeed objectLocation, ISLConstraint con) {
super(cs, rule, objectLocation, con);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import crypto.analysis.errors.AbstractError;
import crypto.analysis.errors.ConstraintError;
import crypto.analysis.errors.ForbiddenMethodError;
import crypto.analysis.errors.HardCodedError;
import crypto.analysis.errors.ImpreciseValueExtractionError;
import crypto.analysis.errors.NeverTypeOfError;
import crypto.extractparameter.CallSiteWithExtractedValue;
Expand Down Expand Up @@ -314,7 +315,7 @@ private void handlePredefinedNames(CryptSLPredicate pred) {
Collection<ExtractedValue> values = parsAndVals.get(cs);
for(ExtractedValue v : values) {
if(isHardCoded(v)) {
errors.add(new NeverTypeOfError(new CallSiteWithExtractedValue(cs, v), classSpec.getRule(), object, pred));
errors.add(new HardCodedError(new CallSiteWithExtractedValue(cs, v), classSpec.getRule(), object, pred));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import crypto.analysis.errors.AbstractError;
import crypto.analysis.errors.ConstraintError;
import crypto.analysis.errors.ForbiddenMethodError;
import crypto.analysis.errors.HardCodedError;
import crypto.analysis.errors.ImpreciseValueExtractionError;
import crypto.analysis.errors.IncompleteOperationError;
import crypto.analysis.errors.NeverTypeOfError;
Expand Down Expand Up @@ -91,6 +92,7 @@ public CSVReporter(String csvReportFileName, String softwareId, List<CryptSLRul
put(Headers.CallGraphReachableMethods_ActiveBodies,callgraphReachableMethodsWithActiveBodies);
addDynamicHeader(ConstraintError.class.getSimpleName());
addDynamicHeader(NeverTypeOfError.class.getSimpleName());
addDynamicHeader(HardCodedError.class.getSimpleName());
addDynamicHeader(TypestateError.class.getSimpleName());
addDynamicHeader(RequiredPredicateError.class.getSimpleName());
addDynamicHeader(IncompleteOperationError.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import crypto.analysis.errors.ConstraintError;
import crypto.analysis.errors.ErrorVisitor;
import crypto.analysis.errors.ForbiddenMethodError;
import crypto.analysis.errors.HardCodedError;
import crypto.analysis.errors.ImpreciseValueExtractionError;
import crypto.analysis.errors.IncompleteOperationError;
import crypto.analysis.errors.NeverTypeOfError;
Expand Down Expand Up @@ -116,6 +117,11 @@ public void visit(NeverTypeOfError neverTypeOfError) {
public void visit(PredicateContradictionError predicateContradictionError) {
addMarker(predicateContradictionError);

}

@Override
public void visit(HardCodedError hardcodedError) {
addMarker(hardcodedError);
}});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class SARIFConfig {
public static final String CONSTRAINT_ERROR_VALUE = "A constraint of a CrySL rule is violated, e.g., a key is generated with the wrong key size.";
public static final String NEVER_TYPE_OF_ERROR_KEY = "NeverTypeOfError";
public static final String NEVER_TYPE_OF_ERROR_VALUE = "Reported when a value was found to be of a certain reference type: For example, a character array containing a password should never be converted from a String";
public static final String HARDCODED_ERROR_KEY = "HardCodedError";
public static final String HARDCODED_ERROR_VALUE = "A hardcoded value was found. Load the value dynamically from a data storage.";
public static final String FORBIDDEN_METHOD_ERROR_KEY = "ForbiddenMethodError";
public static final String FORBIDDEN_METHOD_ERROR_VALUE = "A method that is forbidden (CrySL block FORBIDDEN) to be called under some circumstances was found.";
public static final String IMPRECISE_VALUE_EXTRACTION_ERROR_KEY = "ImpreciseValueExtractionError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import crypto.analysis.errors.ConstraintError;
import crypto.analysis.errors.ErrorVisitor;
import crypto.analysis.errors.ForbiddenMethodError;
import crypto.analysis.errors.HardCodedError;
import crypto.analysis.errors.ImpreciseValueExtractionError;
import crypto.analysis.errors.IncompleteOperationError;
import crypto.analysis.errors.NeverTypeOfError;
Expand Down Expand Up @@ -204,6 +205,11 @@ public void visit(PredicateContradictionError predicateContradictionError) {
}
}
}

@Override
public void visit(HardCodedError predicateError) {

}
});
}

Expand Down

0 comments on commit a1b85ba

Please sign in to comment.