Page MenuHomeSoftware Heritage

api/graph: Handle query parameters that might be passed in graph_query
ClosedPublic

Authored by anlambert on Jan 11 2022, 5:47 PM.

Details

Summary

It is possible to pass query parameters in the graph_query URL argument
of the Web API graph endpoint if the ? character is quoted.

So add extra processing in the endpoint implementation to merge the
query parameters extracted from the graph_query value and those
coming from the django request.

The purpose is to avoid some query parameters to be silently ignored
when requesting the graph API.

Diff Detail

Repository
rDWAPPS Web applications
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 D6919 (id=25065)

Rebasing onto e0a181daf4...

Current branch diff-target is up to date.
Changes applied before test
commit 744c1daec3983870cb79a6e0c543e7b23760cc61
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Tue Jan 11 17:40:34 2022 +0100

    api/graph: Handle query parameters that might be passed in graph_query
    
    It is possible to pass query parameters in the graph_query URL argument
    of the Web API graph endpoint if the ? character is quoted.
    
    So add extra processing in the endpoint implementation to merge the
    query parameters extracted from the graph_query value and those
    coming from the django request.
    
    The purpose is to avoid some query parameters to be silently ignored
    when requesting the graph API.

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

Build is green

Patch application report for D6919 (id=25070)

Rebasing onto 15e6e1988a...

Current branch diff-target is up to date.
Changes applied before test
commit 43525e69eaeb058b5d41c7031c422e7de088af16
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Tue Jan 11 17:40:34 2022 +0100

    api/graph: Handle query parameters that might be passed in graph_query
    
    It is possible to pass query parameters in the graph_query URL argument
    of the Web API graph endpoint if the ? character is quoted.
    
    So add extra processing in the endpoint implementation to merge the
    query parameters extracted from the graph_query value and those
    coming from the django request.
    
    The purpose is to avoid some query parameters to be silently ignored
    when requesting the graph API.

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

seirl requested changes to this revision.Jan 12 2022, 2:17 PM
seirl added a subscriber: seirl.

Minor comment to avoid doing url parsing manually, otherwise LGTM

swh/web/api/views/graph.py
150

I think it's cleaner to use urlunparse() here.

This revision now requires changes to proceed.Jan 12 2022, 2:17 PM
swh/web/api/views/graph.py
150

Better indeed, thanks !

This revision is now accepted and ready to land.Jan 12 2022, 2:50 PM

Build is green

Patch application report for D6919 (id=25091)

Rebasing onto 15e6e1988a...

Current branch diff-target is up to date.
Changes applied before test
commit 9e7732ccebe33b7f4f37ad92a13998136580b2c9
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Tue Jan 11 17:40:34 2022 +0100

    api/graph: Handle query parameters that might be passed in graph_query
    
    It is possible to pass query parameters in the graph_query URL argument
    of the Web API graph endpoint if the ? character is quoted.
    
    So add extra processing in the endpoint implementation to merge the
    query parameters extracted from the graph_query value and those
    coming from the django request.
    
    The purpose is to avoid some query parameters to be silently ignored
    when requesting the graph API.

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