-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example for more abstract coko rules (#844)
Co-authored-by: Selina Lin <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...cation-languages/coko/coko-dsl/src/test/resources/security-example/BlockCipher.codyze.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
interface BlockCiper { | ||
fun algorithm(algo: Any): Op | ||
fun blockLength(length: Any): Op | ||
fun mode(mode: Any): Op | ||
fun padding(pad: Any): Op | ||
} | ||
|
||
|
||
// TODO: need evaluator with condition so we can check if algorithm is AES | ||
@Rule(description = "Check the block length of AES") | ||
fun `correct AES block length`(blockCiper: BlockCiper) = | ||
only(blockCiper.blockLength(listOf(128, 192, 256))) | ||
|
||
@Rule(description = "Check the operation mode of ") | ||
fun `correct mode`(blockCiper: BlockCiper) = | ||
only(blockCiper.mode(listOf("CCM", "GCM", "CBC", "CTR"))) |
24 changes: 24 additions & 0 deletions
24
...languages/coko/coko-dsl/src/test/resources/security-example/BouncyCastleCipher.codyze.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@file:Import("BlockCipher.codyze.kts") | ||
|
||
class Cipher { | ||
|
||
} | ||
|
||
class BouncyCastleBlockCipher: BlockCipher_codyze.BlockCiper { | ||
override fun algorithm(algo: Any): Op { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun blockLength(length: Any): Op { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun mode(mode: Any): Op { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun padding(pad: Any): Op { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} |