Bug 14768 - GitHub git protocol urls need to be scrubbed
Summary: GitHub git protocol urls need to be scrubbed
Status: RESOLVED FIXED
Alias: None
Product: Layer Index
Classification: Yocto Project Subprojects
Component: Layer Index Metadata (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.1 M1
Assignee: Tim Orling
QA Contact: apoorv sangal
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2022-03-24 15:10 UTC by Tim Orling
Modified: 2022-04-20 21:25 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Orling 2022-03-24 15:10:24 UTC
Layers which have git protocol urls for GitHub need to switch to https. GitHub has blocked unauthenticated git protocol.

https://github.blog/2021-09-01-improving-git-protocol-security-github/
Comment 1 Randy MacLeod 2022-03-31 14:36:05 UTC
Is this something that Michael can do in the database?
Comment 2 Konrad Scherer 2022-04-01 13:50:14 UTC
Yes from the Admin interface all the project url for each layers can be updated. 

Django does support custom commands and it should be possible to make a command that will iterate through the layers and update any github urls.
Comment 3 Tim Orling 2022-04-10 18:45:20 UTC
The following should fix it:

UPDATE layerindex_layeritem
    SET layerindex_layeritem.vcs_url = REPLACE(layerindex_layeritem.vcs_url,'git://github.com', 'https://github.com')
    WHERE layerindex_layeritem.vcs_url LIKE "git://github.com%";
Comment 4 Tim Orling 2022-04-11 22:04:39 UTC
After discussing with Paul, we do not want to do SQL directly. I'll need to refactor for 'manage.py shell' which I might have permissions to do (after testing on local instance).
Comment 5 Tim Orling 2022-04-20 17:36:36 UTC
Using manage.py shell:

from django.db.models import Value
from django.db.models.functions import Replace
from layerindex.models import LayerItem

layers = LayerItem.objects.all().filter(vcs_url__startswith='git://github.com')
layers.update(vcs_url=Replace('vcs_url', Value('git://github.com'), Value('https://github.com')))
Comment 6 Tim Orling 2022-04-20 21:25:01 UTC
To get to the shell:
docker exec -it <layersapp> sh -c "/opt/layerindex/manage.py shell"

Count before fix:
106