Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 2120dd5

Browse files
committed
util: os: Create files and dirs with 0o700
Signed-off-by: John Andersen <[email protected]>
1 parent 38c0931 commit 2120dd5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

dffml/service/dev.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pathlib import Path
1919

2020
from ..base import BaseConfig
21-
from ..util.os import chdir
21+
from ..util.os import chdir, MODE_BITS_SECURE
2222
from ..version import VERSION
2323
from ..util.skel import Skel, SkelTemplateConfig
2424
from ..util.cli.arg import Arg
@@ -429,7 +429,7 @@ async def run(self):
429429
with tempfile.TemporaryDirectory() as tempdir:
430430
# The directory where the fresh copy will live
431431
clean_dir = pathlib.Path(tempdir, "clean")
432-
clean_dir.mkdir()
432+
clean_dir.mkdir(mode=MODE_BITS_SECURE)
433433
archive_file = pathlib.Path(tempdir, "archive.tar")
434434
# Create the archive
435435
with open(archive_file, "wb") as archive:

dffml/util/os.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
import contextlib
33

44

5+
# When creating files or directories we should always default to only allowing
6+
# the user to access or edit the files or directories.
7+
MODE_BITS_SECURE = 0o700
8+
9+
510
@contextlib.contextmanager
611
def chdir(new_path):
712
"""

0 commit comments

Comments
 (0)