Allow "Google Internal" in url field

This change adds support for an "Internal" label in the "URL" custom
metadata field. When this label is used, the dependency will be not be
required to provide sufficient metadata for vulnerability coverage.

Change-Id: I747d53934b5ebe3cf4a17fc2aab2de6a9ac2c1dd
Bug: 429937921
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6706140
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Jordan Brown <rop@google.com>
This commit is contained in:
Jordan Brown
2025-07-07 20:42:15 -07:00
committed by LUCI CQ
parent 1b7c452940
commit ab22114f1f
2 changed files with 13 additions and 2 deletions

View File

@@ -24,6 +24,9 @@ import metadata.validation_result as vr
_PATTERN_URL_CANONICAL_REPO = re.compile(
r"^This is the canonical (public )?repo(sitory)?\.?$", re.IGNORECASE)
_PATTERN_URL_INTERNAL = re.compile(
r"^(Google )?internal\.?$", re.IGNORECASE)
_SUPPORTED_SCHEMES = {
'http',
'https',
@@ -75,12 +78,16 @@ class URLField(field_types.MetadataField):
"""Returns if `raw_value` indicates this repository is the canonical repository."""
return util.matches(_PATTERN_URL_CANONICAL_REPO, value.strip())
def repo_is_internal(self, value: str):
"""Returns if `raw_value` indicates this repository is internal."""
return util.matches(_PATTERN_URL_INTERNAL, value.strip())
def validate(self, value: str) -> Optional[vr.ValidationResult]:
"""Checks the given value has acceptable URL values only.
Note: this field supports multiple values.
"""
if self.repo_is_canonical(value):
if self.repo_is_canonical(value) or self.repo_is_internal(value):
return None
urls = _split_urls(value)
@@ -116,7 +123,7 @@ class URLField(field_types.MetadataField):
if not value:
return None
if self.repo_is_canonical(value):
if self.repo_is_canonical(value) or self.repo_is_internal(value):
return None
# Filter out invalid URLs, and canonicalize the URLs.

View File

@@ -196,6 +196,10 @@ class FieldValidationTest(unittest.TestCase):
"ftp://www.example.com/c,git://www.example.com/d",
"https://www.example.com/a\n https://example.com/b",
"This is the canonical public repository",
"internal",
"Internal.",
"Google internal",
"Google Internal.",
],
warning_values=[
# Scheme is case-insensitive, but should be lower case.