Skip to content

Commit 7aff007

Browse files
committed
better safe Flask example
1 parent 0e8f834 commit 7aff007

File tree

1 file changed

+7
-2
lines changed
  • python/ql/src/experimental/Security/CWE-287-ConstantSecretKey/examples

1 file changed

+7
-2
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
"""Flask App configuration."""
2+
import os
23

34
# General Config
45
FLASK_DEBUG = True
5-
SECRET_KEY = "CHANGEME5"
6-
if SECRET_KEY == "CHANGEME5":
6+
# if we are loading SECRET_KEY from config files then
7+
# it is good to check default value always, maybe
8+
# the user responsible for setup the application make a mistake
9+
# and has not changed the default SECRET_KEY value
10+
SECRET_KEY = os.getenv('envKey') # A_CONSTANT_SECRET
11+
if SECRET_KEY == "A_CONSTANT_SECRET":
712
raise "not possible"

0 commit comments

Comments
 (0)