Skip to content

Commit

Permalink
Changed registry.GetDefinitions to use yield (ForensicArtifacts#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Jan 14, 2024
1 parent 1f13d00 commit e7910a8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion artifacts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""ForensicArtifacts.com Artifact Repository."""

__version__ = '20240112'
__version__ = '20240114'
6 changes: 3 additions & 3 deletions artifacts/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def GetDefinitionByName(self, name):
def GetDefinitions(self):
"""Retrieves the artifact definitions.
Returns:
list[ArtifactDefinition]: artifact definitions.
Yields:
ArtifactDefinition: artifact definition.
"""
return self._artifact_definitions_by_name.values()
yield from self._artifact_definitions_by_name.values()

def GetUndefinedArtifacts(self):
"""Retrieves the names of undefined artifacts used by artifact groups.
Expand Down
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
artifacts (20240112-1) unstable; urgency=low
artifacts (20240114-1) unstable; urgency=low

* Auto-generated

-- Forensic artifacts <[email protected]> Fri, 12 Jan 2024 05:40:26 +0100
-- Forensic artifacts <[email protected]> Sun, 14 Jan 2024 05:32:14 +0100
2 changes: 1 addition & 1 deletion docs/sources/background/Stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The artifact definitions can be found in the
[artifacts/data directory](https://github.com/ForensicArtifacts/artifacts/tree/main/artifacts/data) and the format is described
in detail in the [Style Guide](https://artifacts.readthedocs.io/en/latest/sources/Format-specification.html).

Status of the repository as of 2024-01-12
Status of the repository as of 2024-01-14

Description | Number
--- | ---
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = artifacts
version = 20240112
version = 20240114
description = ForensicArtifacts.com Artifact Repository.
long_description = A free, community-sourced, machine-readable knowledge base of forensic artifacts that the world can use both as an information source and within other tools.
long_description_content_type = text/plain
Expand Down
6 changes: 4 additions & 2 deletions tests/registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def testArtifactDefinitionsRegistry(self):
artifact_registry.RegisterDefinition(artifact_definition)

# Make sure the test file got turned into artifacts.
self.assertEqual(len(artifact_registry.GetDefinitions()), 7)
definitions = list(artifact_registry.GetDefinitions())
self.assertEqual(len(definitions), 7)

artifact_definition = artifact_registry.GetDefinitionByName('EventLogs')
self.assertIsNotNone(artifact_definition)
Expand All @@ -75,7 +76,8 @@ def testArtifactDefinitionsRegistry(self):
with self.assertRaises(KeyError):
artifact_registry.DeregisterDefinition(artifact_definition)

self.assertEqual(len(artifact_registry.GetDefinitions()), 6)
definitions = list(artifact_registry.GetDefinitions())
self.assertEqual(len(definitions), 6)

test_artifact_definition = artifact_registry.GetDefinitionByName(
'SecurityEventLogEvtxFile')
Expand Down

0 comments on commit e7910a8

Please sign in to comment.