Skip to content

Commit

Permalink
Rename osim (#390)
Browse files Browse the repository at this point in the history
This PR renames OSIM module to Workflows.

In order to achieve that this PR is separated in 4 commits that
respectively has the purpose of:
- Change the folder name modifying imports, settings and
comments/documentations;
- Change classes, exceptions and models names and attributes to comply
with new naming;
- Change constants names related to the module;
- Change the API path from `/osim/*` to `/workflows/*`.

Closes OSIDB-1395
  • Loading branch information
costaconrado authored Dec 5, 2023
2 parents 7e36a28 + 545fa72 commit 12930e3
Show file tree
Hide file tree
Showing 43 changed files with 482 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .bandit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[bandit]
exclude: osidb/tests, collectors/bzimport/tests, collectors/jiraffe/tests, apps/osim/tests, src, .git, .tox,
exclude: osidb/tests, collectors/bzimport/tests, collectors/jiraffe/tests, apps/workflows/tests, src, .git, .tox,
skips: B101,B102,B301
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Additional functionality is implemented by specialized [apps](apps/).

* [bbsync](apps/bbsync/) Bugzilla Backwards Synchronization
* [exploits](apps/exploits/)
* [osim](apps/osim/) - Open Security Issue Manager
* [workflows](apps/workflows/) - Open Security Issue Manager

Various data sources are being collected by [collectors](collectors/).
They are build on [collector framework](collectors/framework/).
Expand Down
14 changes: 0 additions & 14 deletions apps/osim/apps.py

This file was deleted.

6 changes: 0 additions & 6 deletions apps/osim/constants.py

This file was deleted.

31 changes: 0 additions & 31 deletions apps/osim/exceptions.py

This file was deleted.

27 changes: 0 additions & 27 deletions apps/osim/urls.py

This file was deleted.

File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions apps/osim/api.py → apps/workflows/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
OSIM API endpoints
Workflows API endpoints
"""

import logging
Expand All @@ -12,7 +12,7 @@

from apps.taskman.service import JiraTaskmanQuerier

from .exceptions import OSIMException
from .exceptions import WorkflowsException
from .helpers import get_flaw_or_404, str2bool
from .serializers import (
ClassificationWorkflowSerializer,
Expand All @@ -39,7 +39,7 @@ def get(self, request, *args, **kwargs):
)


# TODO do we need this when OSIM is baked into OSIDB service ?
# TODO do we need this when Workflows is baked into OSIDB service ?
class healthy(APIView):
"""unauthenticated health check API endpoint"""

Expand Down Expand Up @@ -113,7 +113,7 @@ def post(self, request, flaw_id):
"classification": flaw.classification,
}
)
except OSIMException as e:
except WorkflowsException as e:
return Response({"errors": str(e)}, status=status.HTTP_409_CONFLICT)


Expand Down Expand Up @@ -160,7 +160,7 @@ def post(self, request, flaw_id):
"classification": flaw.classification,
}
)
except OSIMException as e:
except WorkflowsException as e:
return Response({"errors": str(e)}, status=status.HTTP_409_CONFLICT)


Expand Down
46 changes: 46 additions & 0 deletions apps/workflows/api_deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Former OSIM API endpoints marked as deprecated
"""

import logging

from drf_spectacular.utils import extend_schema

from apps.workflows import api

logger = logging.getLogger(__name__)


@extend_schema(deprecated=True)
class index(api.index):
"""deprecated osim index API endpoint"""


@extend_schema(deprecated=True)
class healthy(api.healthy):
"""deprecated osim unauthenticated health check API endpoint"""


@extend_schema(deprecated=True)
class adjust(api.adjust):
"""deprecated osim adjustion API endpoint"""


@extend_schema(deprecated=True)
class promote(api.promote):
"""deprecated osim promote API endpoint"""


@extend_schema(deprecated=True)
class reject(api.reject):
"""deprecated osim reject API endpoint"""


@extend_schema(deprecated=True)
class classification(api.classification):
"""deprecated osim classification API endpoint"""


@extend_schema(deprecated=True)
class workflows(api.workflows):
"""deprecated osim info API endpoint"""
13 changes: 13 additions & 0 deletions apps/workflows/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Workflows Manager
"""

from django.apps import AppConfig


class Workflows(AppConfig):
"""django name"""

name = "apps.workflows"
4 changes: 2 additions & 2 deletions apps/osim/checks.py → apps/workflows/checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
OSIM entity requirement check definition
Workflows entity requirement check definition
"""
import inspect

Expand Down Expand Up @@ -38,7 +38,7 @@ class CheckParser(metaclass=MetaCheckParser):
"cve": "cve_id",
"cwe": "cwe_id",
"group": "group_key",
"state": "osim_state",
"state": "workflow_state",
"team": "team_id",
"trackers": "trackers_filed",
}
Expand Down
6 changes: 6 additions & 0 deletions apps/workflows/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Workflows constants
"""

WORKFLOWS_API_VERSION: str = "v1"
WORKFLOW_DIR = "apps/workflows/workflows"
31 changes: 31 additions & 0 deletions apps/workflows/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Workflows exceptions
"""


class WorkflowsException(Exception):
"""base exception class for Workflows specific exceptions"""


class APIError(WorkflowsException):
"""exception class for API errors"""


class LastStateException(WorkflowsException):
"""exception for trying to promote further when in the last possible state"""


class MissingRequirementsException(WorkflowsException):
"""exception for trying to change state without requirements"""


class MissingStateException(WorkflowsException):
"""exception for handling a non-registered state"""


class MissingWorkflowException(WorkflowsException):
"""exception for handling a non-registered workflow"""


class WorkflowDefinitionError(WorkflowsException):
"""exception class for workflow definitions errors"""
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/osim/models.py → apps/workflows/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
OSIM workflow model definitions
Workflows model definitions
"""

from .checks import CheckParser
Expand Down
4 changes: 2 additions & 2 deletions apps/osim/serializers.py → apps/workflows/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
OSIM models serializers
Workflows models serializers
"""

from drf_spectacular.utils import extend_schema_field
Expand Down Expand Up @@ -88,7 +88,7 @@ class Meta:
"workflow": {"type": "string"},
"state": {
"type": "string",
"enum": WorkflowModel.OSIMState.values,
"enum": WorkflowModel.WorkflowState.values,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>OSIM | graph/workflows</title>
<title>Workflows | graph/workflows</title>
</head>
<body>
{% for workflow in workflows %}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from apps.osim.constants import OSIM_API_VERSION
from apps.osim.workflow import WorkflowFramework
from apps.workflows.constants import WORKFLOWS_API_VERSION
from apps.workflows.workflow import WorkflowFramework
from osidb.helpers import get_env


Expand Down Expand Up @@ -35,7 +35,7 @@ def ldap_test_password():

@pytest.fixture
def test_scheme_host():
return "http://osidb-service:8000/osim"
return "http://osidb-service:8000/workflows"


@pytest.fixture
Expand All @@ -45,7 +45,7 @@ def test_scheme_host_osidb():

@pytest.fixture
def api_version():
return OSIM_API_VERSION
return WORKFLOWS_API_VERSION


@pytest.fixture
Expand Down
File renamed without changes.
Loading

0 comments on commit 12930e3

Please sign in to comment.