@@ -667,6 +667,63 @@ def build_bitbucket_purl(url):
667667 )
668668
669669
670+ @purl_router .route ("https?://git\.kernel\\ .org/.*" )
671+ def build_kernel_purl (url ):
672+ """
673+ Return a PackageURL object from Kernel `url`.
674+ For example:
675+ https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=74770b1fd2be612f9c2cf807db81fcdcc35e6560
676+ """
677+
678+ kernel_project_pattern = (
679+ r"^https?://git\.kernel\.org/pub/scm/[^/]+/"
680+ r"(?P<namespace>.+)/"
681+ r"(?P<name>[^/]+?)"
682+ r"(?:\.git)?"
683+ r"/commit/\?id="
684+ r"(?P<version>[0-9a-fA-F]{7,64})/?$"
685+ )
686+
687+ commit_matche = re .search (kernel_project_pattern , url )
688+ if commit_matche :
689+ namespace = "git.kernel.org/" + commit_matche .group ("namespace" )
690+ return PackageURL (
691+ type = "generic" ,
692+ namespace = namespace ,
693+ name = commit_matche .group ("name" ),
694+ version = commit_matche .group ("version" ),
695+ qualifiers = {},
696+ subpath = "" ,
697+ )
698+
699+
700+ @purl_router .route ("https?://android\.googlesource\\ .com/.*" )
701+ def build_android_purl (url ):
702+ """
703+ Return a PackageURL object from Android `url`.
704+ For example:
705+ https://android.googlesource.com/platform/packages/apps/Settings/+/2968ccc911956fa5813a9a6a5e5c8970e383a60f
706+ """
707+
708+ commit_pattern = (
709+ r"^https?://android\.googlesource\.com/"
710+ r"(?P<name>.+)"
711+ r"/\+/"
712+ r"(?P<version>[0-9a-fA-F]{7,64})"
713+ )
714+
715+ commit_matche = re .search (commit_pattern , url )
716+ if commit_matche :
717+ return PackageURL (
718+ type = "generic" ,
719+ namespace = "android.googlesource.com" ,
720+ name = commit_matche .group ("name" ),
721+ version = commit_matche .group ("version" ),
722+ qualifiers = {},
723+ subpath = "" ,
724+ )
725+
726+
670727@purl_router .route ("https?://gitlab\\ .com/(?!.*/archive/).*" )
671728def build_gitlab_purl (url ):
672729 """
0 commit comments