Skip to content

Commit

Permalink
Merge pull request #13 from ocsf/allow-int-to-long
Browse files Browse the repository at this point in the history
Allow int to long
  • Loading branch information
query-jeremy authored Jul 30, 2024
2 parents 3c6b8a0 + 1303344 commit e010f8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ocsf/validate/compatibility/changed_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def validate(self, context: ChangedSchema) -> list[Finding]:
for attr_name, attr in event.attributes.items():
if isinstance(attr, ChangedAttr):
if isinstance(attr.type, Change):
if attr.type.before == "integer_t" and attr.type.after == "long_t":
continue
findings.append(
ChangedTypeFinding(
OcsfElementType.EVENT, name, attr_name, attr.type.before, attr.type.after
Expand All @@ -48,6 +50,8 @@ def validate(self, context: ChangedSchema) -> list[Finding]:
for attr_name, attr in obj.attributes.items():
if isinstance(attr, ChangedAttr):
if isinstance(attr.type, Change):
if attr.type.before == "integer_t" and attr.type.after == "long_t":
continue
findings.append(
ChangedTypeFinding(
OcsfElementType.OBJECT, name, attr_name, attr.type.before, attr.type.after
Expand Down
22 changes: 22 additions & 0 deletions tests/ocsf/validate/compatibility/test_changed_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,25 @@ def test_changed_type_object():
findings = rule.validate(s)
assert len(findings) == 1
assert isinstance(findings[0], ChangedTypeFinding)

def test_int_to_long():
"""Test that changing an int to a long is allowed."""
s = ChangedSchema(
objects={
"process_activity": ChangedObject(
attributes={
"process_name": ChangedAttr(type=Change("integer_t", "long_t")),
}
),
},
classes={
"process_activity": ChangedEvent(
attributes={
"process_name": ChangedAttr(type=Change("integer_t", "long_t")),
}
),
}
)
rule = NoChangedTypesRule()
findings = rule.validate(s)
assert len(findings) == 0

0 comments on commit e010f8a

Please sign in to comment.