From 9a210f556cad95e611576c18aa0f0d6e753dfd9a Mon Sep 17 00:00:00 2001 From: John Hammond Date: Thu, 16 Apr 2020 15:58:44 -0400 Subject: [PATCH 1/2] Added support for Redis password in the configuration file --- app.py | 2 +- config.py | 1 + ctftool | 2 +- daemons/cache_score.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 6d46414..e437268 100644 --- a/app.py +++ b/app.py @@ -88,7 +88,7 @@ def debug_app(): @app.before_request def before_request(): db.connect() - g.redis = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db) + g.redis = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db, password=config.redis.password) g.connected = True diff --git a/config.py b/config.py index 750c0ee..ffa9ef3 100644 --- a/config.py +++ b/config.py @@ -76,6 +76,7 @@ def competition_has_started(): _redis = { 'host': 'localhost', + 'password' : '', 'port': 6379, 'db': 0 } diff --git a/ctftool b/ctftool index a9f61d3..6131baa 100755 --- a/ctftool +++ b/ctftool @@ -168,7 +168,7 @@ def clear_challenges(args): def recache_solves(args): - r = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db) + r = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db, password=config.redis.password) for chal in Challenge.select(): r.hset("solves", chal.id, chal.solves.count()) print(r.hvals("solves")) diff --git a/daemons/cache_score.py b/daemons/cache_score.py index 7c6fed9..b614a1b 100644 --- a/daemons/cache_score.py +++ b/daemons/cache_score.py @@ -6,7 +6,7 @@ def run(): - r = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db) + r = redis.StrictRedis(host=config.redis.host, port=config.redis.port, db=config.redis.db, password=config.redis.password) db.connect() def set_complex(key, val): From 13f1ef77171eae31c92dc9696078c47a6ebd3f52 Mon Sep 17 00:00:00 2001 From: John Hammond Date: Thu, 16 Apr 2020 16:00:54 -0400 Subject: [PATCH 2/2] Corrected default config setting as StrictRedis uses None for password if there is not one set --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index ffa9ef3..f03c563 100644 --- a/config.py +++ b/config.py @@ -76,7 +76,7 @@ def competition_has_started(): _redis = { 'host': 'localhost', - 'password' : '', + 'password' : None, # change this to 'stringOfYourRedisPassword' 'port': 6379, 'db': 0 }