Skip to content

Paths fail to match on Windows #8

@alanisaac

Description

@alanisaac

I tried running ocsf-validator on a Windows system recently. I think there's an issue with the way paths are formed where they are not agnostic to the OS.

The way this manifests is that files that should have inferred schema types do not, and the validator eventually fails:

TESTING: Schema types can be inferred
   WARNING: Unable to detect type of events\application\api.json
   WARNING: Unable to detect type of events\application\application.json
   WARNING: Unable to detect type of events\application\application_lifecycle.json
   WARNING: Unable to detect type of events\application\datastore_activity.json
   WARNING: Unable to detect type of events\application\web_resources_activity.json
   WARNING: Unable to detect type of events\application\web_resource_access_activity.json
   WARNING: Unable to detect type of events\base_event.json
   ...

Encountered an unexpected exception:
Traceback (most recent call last):
  File "C:\git\hub\ocsf-validator\ocsf_validator\runner.py", line 245, in validate
    test(
  File "C:\git\hub\ocsf-validator\ocsf_validator\runner.py", line 192, in test
    code()
  File "C:\git\hub\ocsf-validator\ocsf_validator\runner.py", line 247, in <lambda>
    lambda: validate_include_targets(
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\git\hub\ocsf-validator\ocsf_validator\validators.py", line 137, in validate_include_targets
    process_includes(reader, collector=collector, types=types, update=False)
  File "C:\git\hub\ocsf-validator\ocsf_validator\processor.py", line 449, in process_includes
    for target in parser.extract_targets(path):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\git\hub\ocsf-validator\ocsf_validator\processor.py", line 235, in extract_targets
    if self._types[base] not in [OcsfEvent, OcsfObject]:
       ~~~~~~~~~~~^^^^^^
  File "C:\git\hub\ocsf-validator\ocsf_validator\type_mapping.py", line 29, in __getitem__
    return self._mappings[path]
           ~~~~~~~~~~~~~~^^^^^^
KeyError: 'events\\application\\application.json'

It looks like on Windows, paths are formed with backslashes like objects\user.json whereas the regex matchers are expecting forward slashes e.g. ".*objects/.*json".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions