|
| 1 | +/** |
| 2 | + * Provides default sources, sinks and sanitizers for reasoning about |
| 3 | + * cleartext storage of sensitive information, as well as extension points for |
| 4 | + * adding your own. |
| 5 | + */ |
| 6 | + |
| 7 | +private import ruby |
| 8 | +private import codeql.ruby.DataFlow |
| 9 | +private import codeql.ruby.Concepts |
| 10 | +private import internal.CleartextSources |
| 11 | + |
| 12 | +/** |
| 13 | + * Provides default sources, sinks and sanitizers for reasoning about |
| 14 | + * cleartext storage of sensitive information, as well as extension points for |
| 15 | + * adding your own. |
| 16 | + */ |
| 17 | +module CleartextStorage { |
| 18 | + /** |
| 19 | + * A data flow source for cleartext storage of sensitive information. |
| 20 | + */ |
| 21 | + class Source = CleartextSources::Source; |
| 22 | + |
| 23 | + /** |
| 24 | + * A sanitizer for cleartext storage of sensitive information. |
| 25 | + */ |
| 26 | + class Sanitizer = CleartextSources::Sanitizer; |
| 27 | + |
| 28 | + /** Holds if `nodeFrom` taints `nodeTo`. */ |
| 29 | + predicate isAdditionalTaintStep = CleartextSources::isAdditionalTaintStep/2; |
| 30 | + |
| 31 | + /** |
| 32 | + * A data flow sink for cleartext storage of sensitive information. |
| 33 | + */ |
| 34 | + abstract class Sink extends DataFlow::Node { } |
| 35 | + |
| 36 | + /** |
| 37 | + * A node representing data written to the filesystem. |
| 38 | + */ |
| 39 | + private class FileSystemWriteAccessDataNodeAsSink extends Sink { |
| 40 | + FileSystemWriteAccessDataNodeAsSink() { this = any(FileSystemWriteAccess write).getADataNode() } |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * A node representing data written to a database using an ORM system. |
| 45 | + */ |
| 46 | + private class OrmWriteAccessValueAsSink extends Sink { |
| 47 | + // instanceof OrmWriteAccess { |
| 48 | + // TODO: we generally won't get flow from `value` to `this` |
| 49 | + // Should the node be on value? Or should there be an additional flow step from |
| 50 | + // value to the write node? |
| 51 | + OrmWriteAccessValueAsSink() { |
| 52 | + exists(OrmWriteAccess write, string fieldName | |
| 53 | + fieldName = write.getFieldNameAssignedTo(this) |
| 54 | + ) |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments