Add tests

This commit is contained in:
Joe Farebrother
2022-08-05 17:18:43 +01:00
parent 41bdd6d4cc
commit 9ae652dd6a
4 changed files with 30 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
import javax.crypto.Cipher;
class RsaWithoutOaep {
public void test() throws Exception {
Cipher rsaBad = Cipher.getInstance("RSA/ECB/NoPadding"); // $hasResult
Cipher rsaGood = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
}
}

View File

@@ -0,0 +1,19 @@
import java
import TestUtilities.InlineExpectationsTest
import semmle.code.java.security.RsaWithoutOaepQuery
class HasResult extends InlineExpectationsTest {
HasResult() { this = "HasResult" }
override string getARelevantTag() { result = "hasResult" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasResult" and
value = "" and
exists(MethodAccess ma |
rsaWithoutOaepCall(ma) and
location = ma.getLocation() and
element = ma.toString()
)
}
}