fix(cloud-native): set restrictive file permissions on SQL property f… · JanssenProject/jans@280b2f7 (original) (raw)

Original file line number Diff line number Diff line change
@@ -113,6 +113,8 @@ def test_get_sql_password_from_file(monkeypatch, tmpdir, gmanager):
113 113 ("pgsql", 5432, "public", "postgresql"),
114 114 ])
115 115 def test_render_sql_properties(monkeypatch, tmpdir, gmanager, dialect, port, schema, jdbc_driver):
116 +import os
117 +import stat
116 118 from jans.pycloudlib.persistence.sql import render_sql_properties
117 119
118 120 passwd = tmpdir.join("sql_password")
@@ -145,6 +147,10 @@ def test_render_sql_properties(monkeypatch, tmpdir, gmanager, dialect, port, sch
145 147 render_sql_properties(gmanager, str(src), str(dest))
146 148 assert dest.read() == expected
147 149
150 +# check file permission (should writable only by owner)
151 +perms = stat.S_IMODE(os.stat(dest).st_mode)
152 +assert oct(perms) == '0o600'
153 +
148 154
149 155 class PGException(Exception):
150 156 def __init__(self, code):