Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stix2/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def create(self, cls, **kwargs):
# Use self.defaults as the base, but update with any explicit args
# provided by the user.
properties = copy.deepcopy(self._defaults)

# SCOs do not have these common properties provided by the factory
if "observables" in cls.__module__:
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module name checking approach using string matching is fragile and could break if module structure changes. Consider using a more robust approach like checking if the class is a subclass of _Observable. You would need to import _Observable from .base and then use: issubclass(cls, _Observable) instead of "observables" in cls.__module__.

Copilot uses AI. Check for mistakes.
properties.pop("created", None)
properties.pop("created_by_ref", None)
properties.pop("external_references", None)
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modified property is also set by the factory's set_default_created() method (see line 61) and should be removed for SCOs since they don't have this property. Add properties.pop("modified", None) to ensure the modified property is also removed for observables.

Suggested change
properties.pop("external_references", None)
properties.pop("external_references", None)
properties.pop("modified", None)

Copilot uses AI. Check for mistakes.

Comment on lines +87 to +92
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new functionality for filtering out properties when creating observables lacks test coverage. Consider adding a test that creates an observable (like DomainName) using an ObjectFactory initialized with created_by_ref or created properties to ensure these properties are correctly filtered out.

Copilot uses AI. Check for mistakes.
if kwargs:
if self._list_append:
# Append provided items to list properties instead of replacing them
Expand Down
Loading