changeset 175:c03795ca9975

secret_annotator: returns_secret. A helping method for deciding if the return value of a method can be secret.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Mon, 14 Dec 2009 15:23:52 +0100
parents 0622428b65b2
children f00f9b9dd69d
files pysmcl/secret_annotator.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/secret_annotator.py	Mon Dec 14 11:42:53 2009 +0100
+++ b/pysmcl/secret_annotator.py	Mon Dec 14 15:23:52 2009 +0100
@@ -8,6 +8,13 @@
 
 analysis_key = "secret"
 
+def returns_secret(f):
+    for s in ast.walk(f):
+        if isinstance(s, ast.Return):
+            if expr_secret(s.value):
+                return True
+    return False
+
 def expr_secret(exp, secret_variables = None):
     """
     Returns True if the expression exp should be considered secret