diff --git a/.github/actions/common-setup/action.yml b/.github/actions/common-setup/action.yml new file mode 100644 index 0000000..2d538c0 --- /dev/null +++ b/.github/actions/common-setup/action.yml @@ -0,0 +1,36 @@ +name: 'Project setup' +description: 'Setup Python, Poetry, and install dependencies' +author: 'Wenzel' +inputs: + python_version: + description: 'Python version to setup' + required: true + default: '3.11' +runs: + using: 'composite' + steps: + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python_version }} + + - name: Install Poetry + uses: snok/install-poetry@v1.4 + with: + version: 2.2.1 + + - name: Cache deps + id: cache-deps + uses: actions/cache@v4 + with: + path: ~/.cache/pypoetry + key: pydeps-${{ inputs.python_version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install dependencies + run: poetry install --no-interaction --no-root + shell: bash + if: steps.cache-deps.outputs.cache-hit != 'true' + + - name: Install project + run: poetry install --no-interaction + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e996707 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: + - master + tags: + - '*' + pull_request: + +jobs: + dev: + runs-on: ubuntu-latest + strategy: + matrix: + make_target: [fmt, lint, typing] + include: + - make_target: fmt + extra_args: --check + steps: + - uses: actions/checkout@v4 + + - name: Project setup + uses: ./.github/actions/common-setup + + - name: Run check + run: poetry run poe ${{ matrix.make_target }} ${{ matrix.extra_args }} + + unit_test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: ['3.11', '3.12'] + steps: + - uses: actions/checkout@v4 + + - name: Project setup + uses: ./.github/actions/common-setup + with: + python_version: ${{ matrix.python_version }} + + - name: Run unit tests + run: poetry run poe test-unit + + publish_pypi: + needs: [dev, unit_test] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + environment: pypi + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Project setup + uses: ./.github/actions/common-setup + + - name: Check tag matches package version + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + PKG_VERSION="$(poetry version --short)" + if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then + echo "Tag $GITHUB_REF_NAME ($TAG_VERSION) does not match pyproject version ($PKG_VERSION)" >&2 + exit 1 + fi + + - name: Build and publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + run: poetry publish --build --no-interaction --skip-existing + + release: + needs: [publish_pypi] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get the version + id: get_version + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" + + - name: Create a Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.get_version.outputs.version }} + generate_release_notes: true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index ed8f173..c39238b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,44 @@ -# Grapheos Plugins +# OSWatcher Plugins -Plugin system for GraphEOS to extract and analyze operating system artifacts. +Analysis plugins for [OSWatcher](https://github.com/OSWatcher) — extract and analyze operating system artifacts (filesystem, registry, PDB symbols, syscalls) and store them as a queryable graph in Neo4j. + +## Installation + +```bash +pip install oswatcher-plugins +``` + +## Plugins + +| Plugin | Description | +|--------|-------------| +| `FileTypePlugin` | Identifies file types within OS filesystem snapshots | +| `SymbolsPlugin` | Extracts PDB symbols and struct layouts from PE binaries | +| `WinRegistryPlugin` | Parses and inserts Windows registry hives | +| `SyscallsPlugin` | Extracts Windows/Linux syscall tables | +| `LinuxSymbolsPlugin` | Extracts Linux kernel debug symbols | + +## Usage + +Plugins are run via the `runner` CLI against a [neogit](https://github.com/OSWatcher/neogit) branch: + +```bash +runner +# example: +runner symbols Windows_10_21H2 +``` + +## Requirements + +- Python 3.11+ +- A running Neo4j instance (configured via `neogit` settings) +- [neogit](https://github.com/OSWatcher/neogit) — the underlying graph storage library ## Documentation -- [Syscall Data Model Specification](docs/syscall-data-model.md) - Neo4j data model for Linux and Windows syscall information -- [Neo4j Insertion Pattern](docs/neo4j-insertion-pattern.md) - Architecture for inserting hierarchical data using merkle hashing and visitor pattern \ No newline at end of file +- [Syscall Data Model Specification](docs/syscall-data-model.md) +- [Neo4j Insertion Pattern](docs/neo4j-insertion-pattern.md) + +## License + +Apache 2.0 — see [LICENSE](LICENSE). diff --git a/docs/neo4j-insertion-pattern.md b/docs/neo4j-insertion-pattern.md index 1f2cfc4..e9dfe10 100644 --- a/docs/neo4j-insertion-pattern.md +++ b/docs/neo4j-insertion-pattern.md @@ -905,12 +905,12 @@ FOREACH (ck IN $child_keys | ### Implementation Examples -- **Symbols Plugin**: `/home/wenzel/Projets/grapheos-plugins/plugins/plugins/symbols.py` +- **Symbols Plugin**: [`plugins/plugins/symbols.py`](../plugins/plugins/symbols.py) - Complex hierarchical data (structs with fields, datatypes) - Multiple visitor methods for different node types - Batch insertion with UNWIND -- **Registry Plugin**: `/home/wenzel/Projets/grapheos-plugins/plugins/plugins/registry.py` +- **Registry Plugin**: [`plugins/plugins/registry.py`](../plugins/plugins/registry.py) - Tree-structured data (keys with subkeys and values) - Separation of Blob vs Tree children - Recursive insertion pattern @@ -925,4 +925,4 @@ FOREACH (ck IN $child_keys | ### Related Documentation - [Syscall Data Model Specification](syscall-data-model.md) - Specific application for syscall data -- [Diff Algorithm Documentation](/home/wenzel/Projets/osw-frontend/docs/reference/architecture.md) - Why relationship `name` property is required +- Diff Algorithm Documentation (`osw-frontend` repo — `docs/reference/architecture.md`) - Why relationship `name` property is required diff --git a/docs/syscall-data-model.md b/docs/syscall-data-model.md index b95304d..214983f 100644 --- a/docs/syscall-data-model.md +++ b/docs/syscall-data-model.md @@ -417,7 +417,7 @@ This enables: ## GraphQL Schema Integration -The syscall data model will be added to `/home/wenzel/Projets/graphql-api/type-defs.graphql`: +The syscall data model will be added to `graphql-api/type-defs.graphql` in the [graphql-api](https://github.com/OSWatcher/graphql-api) repository: ```graphql type SyscallTable implements Hashable { @@ -466,6 +466,5 @@ type Blob implements Hashable { ## References -- Diff algorithm documentation: `/home/wenzel/Projets/osw-frontend/docs/reference/architecture.md` (Section 4) -- Diff algorithm implementation: `/home/wenzel/Projets/grapheos-procedures/src/main/java/example/TreeDiffRecursiveProcedure.java` -- Plugin implementation: `/home/wenzel/Projets/grapheos-plugins/plugins/plugins/syscalls.py` +- Diff algorithm implementation: `grapheos-procedures` repo — `src/main/java/example/TreeDiffRecursiveProcedure.java` +- Plugin implementation: [`plugins/plugins/syscalls.py`](../plugins/plugins/syscalls.py) diff --git a/plugins/plugins/registry.py b/plugins/plugins/registry.py index 359039c..2f9c238 100644 --- a/plugins/plugins/registry.py +++ b/plugins/plugins/registry.py @@ -93,7 +93,9 @@ class WinRegMerkleVisitor(MerkleVisitor): def visit_WinRegValueNode(self, node: WinRegValueNode, hash_obj: hashlib._Hash, *args, **kwargs) -> VisitedNode: hash_obj.update(f"{node.value.name}{node.value.value}{node.value.value_type}".encode()) - merkle_node = WinRegValueMerkleNode(hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, value=node.value) + merkle_node = WinRegValueMerkleNode( # type: ignore[call-arg] + hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, value=node.value + ) return VisitedNode(node, merkle_node) def visit_WinRegKeyNode(self, node: WinRegKeyNode, hash_obj: hashlib._Hash, *args, **kwargs) -> VisitedNode: @@ -114,7 +116,7 @@ def visit_WinRegKeyNode(self, node: WinRegKeyNode, hash_obj: hashlib._Hash, *arg # merkle_node.children.clear() merkle_children[child_node.name] = merkle_node # compute final hash - merkle_node = WinRegKeyMerkleNode( + merkle_node = WinRegKeyMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), children=merkle_children, label=MerkleLabel.Tree, key=node.key ) return VisitedNode(node, merkle_node) diff --git a/plugins/plugins/symbols.py b/plugins/plugins/symbols.py index 3f605b5..8cd7bae 100644 --- a/plugins/plugins/symbols.py +++ b/plugins/plugins/symbols.py @@ -157,7 +157,7 @@ def __attrs_post_init__(self): def iter_child_nodes(self) -> Generator[Node, None, None]: match self.kind: case FieldKindType.Array | FieldKindType.Bitfield | FieldKindType.Pointer: - yield DataTypeNode(data_type=self.subtype) + yield DataTypeNode(data_type=self.subtype) # type: ignore[arg-type] @define(auto_attribs=True) @@ -196,7 +196,7 @@ def visit_DataTypeNode(self, node: DataTypeNode, hash_obj: hashlib._Hash, *args, | FieldKindType.Function ): hash_obj.update(f"{node.name}".encode()) - merkle_node = DataTypeMerkleNode( + merkle_node = DataTypeMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, kind=node.kind, name=node.name ) return VisitedNode(node, merkle_node) @@ -206,7 +206,7 @@ def visit_DataTypeNode(self, node: DataTypeNode, hash_obj: hashlib._Hash, *args, merkle_node = visited_node.return_value data = f"{merkle_node.hash}-{node.array_counter}\n".encode() hash_obj.update(data) - merkle_node = DataTypeMerkleNode( + merkle_node = DataTypeMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, kind=node.kind, @@ -220,7 +220,7 @@ def visit_DataTypeNode(self, node: DataTypeNode, hash_obj: hashlib._Hash, *args, merkle_node = visited_node.return_value data = f"{merkle_node.hash}-{node.bit_length}-{node.bit_position}\n".encode() hash_obj.update(data) - merkle_node = DataTypeMerkleNode( + merkle_node = DataTypeMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, kind=node.kind, @@ -235,7 +235,7 @@ def visit_DataTypeNode(self, node: DataTypeNode, hash_obj: hashlib._Hash, *args, merkle_node = visited_node.return_value data = f"{merkle_node.hash}\n".encode() hash_obj.update(data) - merkle_node = DataTypeMerkleNode( + merkle_node = DataTypeMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, kind=node.kind, @@ -244,7 +244,7 @@ def visit_DataTypeNode(self, node: DataTypeNode, hash_obj: hashlib._Hash, *args, return VisitedNode(node, merkle_node) def visit_StructFieldNode(self, node: StructFieldNode, hash_obj: hashlib._Hash, *args, **kwargs) -> VisitedNode: - children = {} + children: dict = {} # for data_type in node.iter_child_nodes(): # visited_node = self.visit(data_type) # merkle_node = visited_node.return_value @@ -253,7 +253,7 @@ def visit_StructFieldNode(self, node: StructFieldNode, hash_obj: hashlib._Hash, # children[merkle_node.hash] = merkle_node # merklize the offset and the data type string hash_obj.update(f"{node.offset}-{node.data_type}".encode()) - merkle_node = StructFieldMerkleNode( + merkle_node = StructFieldMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, name=node.name, @@ -273,7 +273,7 @@ def visit_StructNode(self, node: StructNode, hash_obj: hashlib._Hash, *args, **k hash_obj.update(data) children[member.name] = merkle_node hash_obj.update(f"{node.size}-{node.kind.name}".encode()) - merkle_node = StructMerkleNode( + merkle_node = StructMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), children=children, label=MerkleLabel.Tree, @@ -337,7 +337,7 @@ def retrieve_pdb(guid, age, pdb_name) -> str: @define(auto_attribs=True) class SymbolsPlugin(AbstractPlugin): max_workers: int = field(init=False, default=os.cpu_count()) - _repository: SymbolsRepository = field(init=False, default=None) + _repository: Optional[SymbolsRepository] = field(init=False, default=None) PE_MIME_TYPE = "application/vnd.microsoft.portable-executable" # only process these filenames for now @@ -357,7 +357,7 @@ def repository(self) -> SymbolsRepository: self._repository = SymbolsRepository(self.neogit) return self._repository - def constraints_data(self) -> lief.List[UniqueConstraint]: + def constraints_data(self) -> list[UniqueConstraint]: return [ UniqueConstraint(label="Symbol", property_list=["hash"]), UniqueConstraint(label="Struct", property_list=["hash"]), @@ -408,7 +408,7 @@ def stage_parse_code_view(self, blob_result: Tuple[PurePath, str]) -> Optional[T return blob_hash, *ret @return_exceptions - def stage_process_pdb(self, arg) -> Tuple[str, Path]: + def stage_process_pdb(self, arg) -> Tuple[str, str, Path]: blob_hash, guid, age, pdb_name = arg try: location = retrieve_pdb(guid, age, pdb_name) diff --git a/plugins/plugins/syscalls.py b/plugins/plugins/syscalls.py index bf00d11..808c7a7 100644 --- a/plugins/plugins/syscalls.py +++ b/plugins/plugins/syscalls.py @@ -77,7 +77,7 @@ def _extract_syscalls_from_repo(self, kernel_info_list: List[KernelInfo]) -> Dic Dictionary mapping kernel version to list of syscall data """ syscall_data = {} - cache_dir = appdirs.user_cache_dir("grapheos-plugins") + cache_dir = appdirs.user_cache_dir("oswatcher-plugins") self.logger.info(f"Cloning/updating Linux kernel repository to {cache_dir}") repo = ensure_kernel_repo(cache_dir) diff --git a/plugins/syscalls/nodes.py b/plugins/syscalls/nodes.py index a5a1520..3429e47 100644 --- a/plugins/syscalls/nodes.py +++ b/plugins/syscalls/nodes.py @@ -76,7 +76,7 @@ def visit_SyscallNode(self, node: SyscallNode, hash_obj: hashlib._Hash, *args, * data = f"{node.index}-{node.name}-{node.entry_point}-{params_json}".encode() hash_obj.update(data) - merkle_node = SyscallMerkleNode( + merkle_node = SyscallMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), label=MerkleLabel.Blob, # Leaf node name=node.name, @@ -110,7 +110,7 @@ def visit_SyscallTableNode(self, node: SyscallTableNode, hash_obj: hashlib._Hash # Add table metadata hash_obj.update(f"{node.architecture}".encode()) - merkle_node = SyscallTableMerkleNode( + merkle_node = SyscallTableMerkleNode( # type: ignore[call-arg] hash=hash_obj.hexdigest(), children=children, label=MerkleLabel.Tree, # Internal node diff --git a/plugins/syscalls/syscalls_h_parser.py b/plugins/syscalls/syscalls_h_parser.py index 8d6122b..245a0ee 100644 --- a/plugins/syscalls/syscalls_h_parser.py +++ b/plugins/syscalls/syscalls_h_parser.py @@ -36,7 +36,7 @@ def parse_syscall_signature(syscalls_h_content: str, entry_name: str) -> Optiona # Handle void case if params_str.strip() == "void": - parameters = [] + parameters: list = [] else: # Split by comma and clean up parameters = [] diff --git a/poetry.lock b/poetry.lock index b1b1094..0720cb8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -994,37 +994,34 @@ pyarrow = ["pyarrow (>=1.0.0)"] [[package]] name = "neogit" -version = "0.13.1" +version = "0.16.0" description = "Git-like tool backed by Neo4j" optional = false -python-versions = "^3.11" +python-versions = "<4.0,>=3.10" groups = ["main"] -files = [] -develop = false +files = [ + {file = "neogit-0.16.0-py3-none-any.whl", hash = "sha256:7ff561bddd6e30e1459358fa1d7815311fce5ee327ec998cd060e927f612a416"}, + {file = "neogit-0.16.0.tar.gz", hash = "sha256:6d7776888ee82da584973c436f67667abf4511a275e0b6c04a227d7796601943"}, +] [package.dependencies] apache-libcloud = "3.8.0" appdirs = "1.4.4" -attrs = "^23.2.0" +attrs = ">=23.2.0,<24.0.0" coloredlogs = "15.0" docopt = "0.6.2" dynaconf = "3.2.5" fasteners = "0.16" -ipdb = "^0.13.13" +ipdb = ">=0.13.13,<0.14.0" more-itertools = "8.7.0" neo4j = "5.19" neomodel = "5.3.2" -poethepoet = "^0.26.1" +poethepoet = ">=0.26.1,<0.27.0" py2neo-history = "2021.2.0" PyYAML = "6.0.1" -rich = "14.0.0" -types-PyYAML = "^6.0.0" - -[package.source] -type = "git" -url = "https://github.com/OSWatcher/neogit.git" -reference = "v0.13.3" -resolved_reference = "f67bf2c9dffdf1047a9c9c1e0009ae6ed030b7a7" +rich = ">=15.0.0,<16.0.0" +types-PyYAML = ">=6.0.0,<7.0.0" +typing-extensions = ">=4.0.0,<5.0.0" [[package]] name = "neomodel" @@ -1537,14 +1534,14 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "rich" -version = "14.0.0" +version = "15.0.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false -python-versions = ">=3.8.0" +python-versions = ">=3.9.0" groups = ["main"] files = [ - {file = "rich-14.0.0-py3-none-any.whl", hash = "sha256:1c9491e1951aac09caffd42f448ee3d04e58923ffe14993f6e83068dc395d7e0"}, - {file = "rich-14.0.0.tar.gz", hash = "sha256:82f1bc23a6a21ebca4ae0c45af9bdbc492ed20231dcb63f297d6d1021a9d5725"}, + {file = "rich-15.0.0-py3-none-any.whl", hash = "sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb"}, + {file = "rich-15.0.0.tar.gz", hash = "sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36"}, ] [package.dependencies] @@ -1873,7 +1870,6 @@ files = [ {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, ] -markers = {main = "python_version < \"3.13\""} [[package]] name = "urllib3" @@ -1930,4 +1926,4 @@ files = [ [metadata] lock-version = "2.1" python-versions = "^3.11" -content-hash = "6d63660fffbbc21e19dcd1336d199f1d07e5d52db5bf5d782fbffad784506110" +content-hash = "6ce9b4b2f1491e1106e5bffc6b04fc422a50496db8442401b1c4740d364ea25f" diff --git a/pyproject.toml b/pyproject.toml index 6b5780c..a184d05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,17 @@ [tool.poetry] -name = "plugins" -version = "0.13.2" -description = "" +name = "oswatcher-plugins" +version = "0.14.0" +description = "Analysis plugins for OSWatcher — extract and analyze OS artifacts into Neo4j" authors = ["Mathieu Tarral "] -license = "private" +license = "Apache-2.0" readme = "README.md" +homepage = "https://github.com/OSWatcher/oswatcher-plugins" +repository = "https://github.com/OSWatcher/oswatcher-plugins" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", +] +packages = [{include = "plugins"}] [build-system] requires = ["poetry-core"] @@ -15,7 +22,7 @@ runner = 'plugins.__main__:runner' [tool.poetry.dependencies] python = "^3.11" -neogit = { git = "https://github.com/OSWatcher/neogit.git", tag = "v0.13.3" } +neogit = "^0.16.0" poethepoet = "^0.26.1" ipdb = "^0.13.13" click = "^8.1.7" @@ -85,6 +92,10 @@ show_column_numbers = true show_error_codes = true pretty = true +[[tool.mypy.overrides]] +module = ["neogit.*", "dynaconf.*", "ipdb.*", "lief.*", "regipy.*", "pypeln.*", "volatility3.*"] +ignore_missing_imports = true + [tool.pytest.ini_options] markers = [ "integration: marks tests as integration tests (may be slow)",