diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54e9764a..0c2a3960 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - - uses: abatilo/actions-poetry@v2 + - uses: abatilo/actions-poetry@v3 with: poetry-version: ${{ env.POETRY_VERSION }} - run: poetry install @@ -46,15 +46,18 @@ jobs: pytest: name: pytest runs-on: ubuntu-latest + needs: + - linting + - version steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - - uses: abatilo/actions-poetry@v2 + - uses: abatilo/actions-poetry@v3 with: poetry-version: ${{ env.POETRY_VERSION }} - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 - run: poetry install - run: go install github.com/richardlehane/siegfried/cmd/sf@latest - name: Unit test diff --git a/acacore/__version__.py b/acacore/__version__.py index f5f41e56..d539d50c 100644 --- a/acacore/__version__.py +++ b/acacore/__version__.py @@ -1 +1 @@ -__version__ = "3.1.0" +__version__ = "3.1.1" diff --git a/acacore/models/file.py b/acacore/models/file.py index 80ac440e..0d070676 100644 --- a/acacore/models/file.py +++ b/acacore/models/file.py @@ -288,11 +288,13 @@ def get_action( action: Action | None = reduce(lambda acc, cur: acc or actions.get(cur), identifiers, None) if action and action.alternatives and (new_puid := action.alternatives.get(self.suffixes.lower(), None)): - puid: str = self.puid + puid: str | None = self.puid self.puid = new_puid - if new_action := self.get_action(actions, file_classes, set_match=set_match): - return new_action - self.puid = puid + if new_action := self.get_action(actions, file_classes): + action = new_action + self.signature = action.name + else: + self.puid = puid if set_match: self.action, self.action_data = ( diff --git a/acacore/models/reference_files.py b/acacore/models/reference_files.py index 89ff5dfe..469edef1 100644 --- a/acacore/models/reference_files.py +++ b/acacore/models/reference_files.py @@ -47,13 +47,22 @@ class CustomSignature(BaseModel): :param extension: The file extension associated with the signature. """ + puid: str + signature: str bof: str | None = None eof: str | None = None operator: str | None = None - puid: str | None = None - signature: str | None = None extension: str | None = None + # noinspection PyNestedDecorators + @model_validator(mode="after") + def _validate_model(self) -> Self: + if not self.bof and not self.eof: + raise ValueError("One of bof or eof must be set.") + if self.bof and self.eof and not self.operator: + raise ValueError("Operator must be set if both bof and eof are set.") + return self + class IgnoreIfAction(NoDefaultsModel): """ diff --git a/pyproject.toml b/pyproject.toml index b5a32b7d..7024d674 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "acacore" -version = "3.1.0" +version = "3.1.1" description = "" authors = ["Matteo Campinoti "] license = "GPL-3.0"