Skip to content

Commit

Permalink
allow only one fragment for paths with leading slash
Browse files Browse the repository at this point in the history
  • Loading branch information
huettenhain committed Oct 22, 2024
1 parent c73a371 commit b116729
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion refinery/lib/patterns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def display(self):
p=_pattern_win_path_element
)

_pattern_nix_path = R'\b/?(?:{n}/){{2,}}{n}\b'.format(n=_pattern_nix_path_element)
_pattern_nix_path = R'(?:/(?:{n}/)+|(?:{n}/){{2,}}){n}'.format(n=_pattern_nix_path_element)
_pattern_any_path = R'(?:{nix})|(?:{win})'.format(
nix=_pattern_nix_path,
win=_pattern_win_path
Expand Down
3 changes: 3 additions & 0 deletions test/lib/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ class here_string:
def test_guid_in_path(self):
self.assertTrue(indicators.path.fullmatch(
RB'C:\Users\W10PRO~1\AppData\Local\Temp\{CAE44DB5-22DC-4A76-B334-E77C8D459505}\word_data.bin'))

def test_two_part_path(self):
self.assertTrue(indicators.path.fullmatch(RB'/root/something_something_in_the_root.txt'))

0 comments on commit b116729

Please sign in to comment.