Page MenuHomeSoftware Heritage

FUSE: fs: lookup: add optional regexp name validation
ClosedPublic

Authored by haltode on Dec 8 2020, 4:51 PM.

Diff Detail

Repository
rDFUSE FUSE virtual file system
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4689 (id=16640)

Rebasing onto 8515c5171d...

Current branch diff-target is up to date.
Changes applied before test
commit 1880b03749a04aa35befa0dd1e4d721eeae656b5
Author: Thibault Allançon <haltode@gmail.com>
Date:   Tue Dec 8 16:42:46 2020 +0100

    fs: lookup: add optional regexp name validation
    
    Close T2863.

See https://jenkins.softwareheritage.org/job/DFUSE/job/tests-on-diff/233/ for more details.

seirl added a subscriber: seirl.
seirl added inline comments.
swh/fuse/fs/artifact.py
330

You don't want to have anything of the regex inside the fstring in case you need more changes, and then you don't need an fstring only for SWHID_REGEXP.

Why not simply:

ENTRIES_REGEXP = r"^([a-f0-9]+)|(" + SWHID_REGEXP + ")$"

If that's too ugly, the other option is to use {{ and }} to escape the ranges.

This revision is now accepted and ready to land.Dec 8 2020, 4:55 PM
zack requested changes to this revision.Dec 8 2020, 5:12 PM
zack added a subscriber: zack.
zack added inline comments.
swh/fuse/fs/entry.py
80–89

This way regexs are re-compiled at each check, which isn't great.

ENTRIES_REGEXP should have as type something like Optional[re.Pattern], and the default implementation of validate_entry should do nothing if the regex is None.

This revision now requires changes to proceed.Dec 8 2020, 5:12 PM
  • Use Optional[Pattern] instead of str (and default to None)
  • Use re.compile to initialize regexp

Build is green

Patch application report for D4689 (id=16643)

Rebasing onto 8515c5171d...

Current branch diff-target is up to date.
Changes applied before test
commit 6e413667a22084fd3b30e914f214bb3344aef9bc
Author: Thibault Allançon <haltode@gmail.com>
Date:   Tue Dec 8 16:42:46 2020 +0100

    fs: lookup: add optional regexp name validation
    
    Close T2863.

See https://jenkins.softwareheritage.org/job/DFUSE/job/tests-on-diff/234/ for more details.

This revision is now accepted and ready to land.Dec 8 2020, 5:19 PM