Page MenuHomeSoftware Heritage

Prevent repository normalization from crashing on malformed input.
ClosedPublic

Authored by vlorentz on Jan 15 2019, 3:57 PM.

Diff Detail

Repository
rDCIDX Metadata indexer
Branch
harden-maven-repository
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 3512
Build 4550: tox-on-jenkinsJenkins
Build 4549: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Jan 15 2019, 4:57 PM
douardda added inline comments.
swh/indexer/metadata_dictionary.py
276โ€“284

I find this code a bit bloated.

Is it possible to have something other than a str or None for these values? (url, group and artifact) ?

Isn't this code enough?

if 'url' not in repo or repo.get('layout', 'default') != 'default':
    return
group_id = d.get('groupId', '')
artifact_id = d.get('artifactId', '')
url = os.path.join(repo['url'], group_id.replace('.', '/'), artifact_id)
return {'@id': url}

Hard to tell since it seems this method has no unit test ๐Ÿ˜ˆ

This revision was automatically updated to reflect the committed changes.