diff --git a/.flake8 b/.flake8 index 07c407f7f..d404e7fda 100644 --- a/.flake8 +++ b/.flake8 @@ -27,3 +27,8 @@ per-file-ignores = # this file overwrites methods from the logging library so we can't change them # and ignore long comment line spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py:N802,B950 + + # TODO: fix the S issues: + # S607 Starting a process with a partial executable path + # S605 Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell + spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py:S607,S101,D103,S605 diff --git a/spiffworkflow-backend/.flake8 b/spiffworkflow-backend/.flake8 index 16f7c5591..1cc09c979 100644 --- a/spiffworkflow-backend/.flake8 +++ b/spiffworkflow-backend/.flake8 @@ -27,3 +27,5 @@ per-file-ignores = # this file overwrites methods from the logging library so we can't change them # and ignore long comment line src/spiffworkflow_backend/services/logging_service.py:N802,B950 + + tests/spiffworkflow_backend/integration/test_process_api.py:S607,S101,D103,S605 diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/dev.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/dev.py index f20189e9f..182d08dec 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/dev.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/dev.py @@ -1,6 +1,8 @@ -"""dev.""" +"""Dev.""" from os import environ GIT_MERGE_BRANCH = environ.get("GIT_MERGE_BRANCH", default="staging") GIT_USERNAME = environ.get("GIT_USERNAME", default="sartography-automated-committer") -GIT_USER_EMAIL = environ.get("GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com") +GIT_USER_EMAIL = environ.get( + "GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com" +) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py index 0567120db..eb37afcab 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py @@ -2,7 +2,7 @@ import os from contextlib import contextmanager from datetime import datetime -from typing import List +from typing import Generator, List from typing import Optional import pytz @@ -25,9 +25,9 @@ class FileSystemService: PROCESS_MODEL_JSON_FILE = "process_model.json" # https://stackoverflow.com/a/24176022/6090676 - @contextmanager @staticmethod - def cd(newdir): + @contextmanager + def cd(newdir: str) -> Generator: """Cd.""" prevdir = os.getcwd() os.chdir(os.path.expanduser(newdir)) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py index d0d459186..4a9037362 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py @@ -44,7 +44,7 @@ class GitService: return file_contents.encode("utf-8") @staticmethod - def commit(message: str, repo_path: Optional[str]) -> str: + def commit(message: str, repo_path: Optional[str] = None) -> str: """Commit.""" repo_path_to_use = repo_path if repo_path is None: @@ -73,10 +73,14 @@ class GitService: clone_dir = f"sample-process-models.{unique_hex}" # clone new instance of sample-process-models, checkout branch_to_update - destination_process_root = f"/tmp/{clone_dir}" - os.system( - f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}@github.com/sartography/sample-process-models.git {destination_process_root}" + # we are adding a guid to this so the flake8 issue has been mitigated + destination_process_root = f"/tmp/{clone_dir}" # noqa + + cmd = ( + f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}" + f"@github.com/sartography/sample-process-models.git {destination_process_root}" ) + os.system(cmd) # noqa: S605 with FileSystemService.cd(destination_process_root): # create publish branch from branch_to_update os.system(f"git checkout {branch_to_update}") # noqa: S605 @@ -84,7 +88,7 @@ class GitService: command = f"git show-ref --verify refs/remotes/origin/{publish_branch}" output = os.popen(command).read() # noqa: S605 if output: - os.system(f"git checkout {publish_branch}") + os.system(f"git checkout {publish_branch}") # noqa: S605 else: os.system(f"git checkout -b {publish_branch}") # noqa: S605 @@ -99,10 +103,10 @@ class GitService: # add and commit files to publish_branch, then push commit_message = f"Request to publish changes to {process_model_id}, from {g.user.username}" cls.commit(commit_message, destination_process_root) - os.system("git push") + os.system("git push") # noqa # build url for github page to open PR - output = os.popen("git config --get remote.origin.url").read() + output = os.popen("git config --get remote.origin.url").read() # noqa remote_url = output.strip().replace(".git", "") pr_url = f"{remote_url}/compare/{publish_branch}?expand=1" diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index d3abd7320..e7edae605 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -2664,7 +2664,7 @@ class TestProcessApi(BaseTest): assert "process_model.json" in listing assert "new_file.txt" in listing - modified_process_model_id = process_model_identifier.replace("/", ":") + # modified_process_model_id = process_model_identifier.replace("/", ":") # response = client.post( # f"/v1.0/process-models/{modified_process_model_id}/publish?branch_to_update=staging", # headers=self.logged_in_headers(with_super_admin_user), diff --git a/spiffworkflow-frontend/.gitignore b/spiffworkflow-frontend/.gitignore index a694da806..8ff3e35ce 100644 --- a/spiffworkflow-frontend/.gitignore +++ b/spiffworkflow-frontend/.gitignore @@ -29,4 +29,4 @@ cypress/screenshots /test*.json # Editors -.idea \ No newline at end of file +.idea diff --git a/spiffworkflow-frontend/public/index.html b/spiffworkflow-frontend/public/index.html index 8e5b00b0f..ae3a23076 100644 --- a/spiffworkflow-frontend/public/index.html +++ b/spiffworkflow-frontend/public/index.html @@ -41,4 +41,3 @@ --> - diff --git a/spiffworkflow-frontend/src/index.css b/spiffworkflow-frontend/src/index.css index 5701a4f1d..248a23d7d 100644 --- a/spiffworkflow-frontend/src/index.css +++ b/spiffworkflow-frontend/src/index.css @@ -370,4 +370,3 @@ svg.notification-icon { .tag-type-green:hover { background-color: #80ee90; } -