Skip to content

Commit 91f2bb7

Browse files
htuchmoderation
andauthored
dependencies: compute and check release dates via GitHub API. (envoyproxy#13582)
The use of last_updated was ambiguous (is it when an Envoy contributor creates a PR, merges a commit, or when the dependency is released?). We really are after the release date as a measure of how stale the dependency is. This patch introduces a tool, tools/dependency/release_dates.py, that uses the GitHub API to compute release date. If a mismatch is detected, an error is raised. This patch also introduces a dependency validation CI job that gathers existing scripts and the release_dates.py script into a single job. Signed-off-by: Harvey Tuch <[email protected]> Co-authored-by: Michael Payne <[email protected]>
1 parent 748b2ab commit 91f2bb7

19 files changed

+354
-158
lines changed

.azure-pipelines/pipelines.yml

+15
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ stages:
8787
AZP_BRANCH: $(Build.SourceBranch)
8888
AZP_SHA1: $(Build.SourceVersion)
8989
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['PostSubmit'], true))
90+
- job: dependencies
91+
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel.
92+
pool:
93+
vmImage: "ubuntu-18.04"
94+
steps:
95+
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh deps'
96+
workingDirectory: $(Build.SourcesDirectory)
97+
env:
98+
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
99+
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
100+
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
101+
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
102+
GITHUB_TOKEN: $(GitHubPublicRepoOnlyAccessToken)
103+
displayName: "Verify dependency information"
104+
90105

91106
- stage: sync
92107
condition: and(succeeded(), eq(variables['PostSubmit'], true))

DEPENDENCY_POLICY.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ Dependency declarations must:
4545
version is being used.
4646
* Provide accurate entries for `use_category`. Please think carefully about whether there are data
4747
or control plane implications of the dependency.
48-
* Reflect the date (YYYY-MM-DD) at which they were last updated in the `last_updated` field. This
49-
date is preferably the date at which the PR is created.
48+
* Reflect the UTC date (YYYY-MM-DD format) for the dependency release. This is when
49+
the dependency was updated in its repository. For dependencies that have
50+
releases, this is the date of the release. For dependencies without releases
51+
or for scenarios where we temporarily need to use a commit, this date should
52+
be the date of the commit in UTC.
5053
* CPEs are compulsory for all dependencies that are not purely build/test.
5154
[CPEs](https://en.wikipedia.org/wiki/Common_Platform_Enumeration) provide metadata that allow us
5255
to correlate with related CVEs in dashboards and other tooling, and also provide a machine

api/bazel/external_deps.bzl

+13-10
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ DEPENDENCY_ANNOTATIONS = [
1717
# Envoy (see the external dependency at the given version for information).
1818
"implied_untracked_deps",
1919

20-
# When the dependency was last updated in Envoy.
21-
"last_updated",
22-
2320
# Project metadata.
2421
"project_desc",
2522
"project_name",
2623
"project_url",
2724

25+
# Reflects the UTC date (YYYY-MM-DD format) for the dependency release. This
26+
# is when the dependency was updated in its repository. For dependencies
27+
# that have releases, this is the date of the release. For dependencies
28+
# without releases or for scenarios where we temporarily need to use a
29+
# commit, this date should be the date of the commit in UTC.
30+
"release_date",
31+
2832
# List of the categories describing how the dependency is being used. This attribute is used
2933
# for automatic tracking of security posture of Envoy's dependencies.
3034
# Possible values are documented in the USE_CATEGORIES list below.
@@ -63,8 +67,7 @@ USE_CATEGORIES = [
6367
"devtools",
6468
]
6569

66-
# Components with these use categories are not required to specify the 'cpe'
67-
# and 'last_updated' annotation.
70+
# Components with these use categories are not required to specify the 'cpe'.
6871
USE_CATEGORIES_WITH_CPE_OPTIONAL = ["build", "other", "test_only", "api"]
6972

7073
def _fail_missing_attribute(attr, key):
@@ -106,13 +109,13 @@ def load_repository_locations(repository_locations_spec):
106109
if "extensions" not in location:
107110
_fail_missing_attribute("extensions", key)
108111

109-
if "last_updated" not in location:
110-
_fail_missing_attribute("last_updated", key)
111-
last_updated = location["last_updated"]
112+
if "release_date" not in location:
113+
_fail_missing_attribute("release_date", key)
114+
release_date = location["release_date"]
112115

113116
# Starlark doesn't have regexes.
114-
if len(last_updated) != 10 or last_updated[4] != "-" or last_updated[7] != "-":
115-
fail("last_updated must match YYYY-DD-MM: " + last_updated)
117+
if len(release_date) != 10 or release_date[4] != "-" or release_date[7] != "-":
118+
fail("release_date must match YYYY-DD-MM: " + release_date)
116119

117120
if "cpe" in location:
118121
cpe = location["cpe"]

api/bazel/repository_locations.bzl

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
77
version = "1.0.3",
88
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
99
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz"],
10-
last_updated = "2020-08-27",
10+
release_date = "2020-08-27",
1111
use_category = ["api"],
1212
),
1313
com_envoyproxy_protoc_gen_validate = dict(
@@ -18,7 +18,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
1818
sha256 = "e368733c9fb7f8489591ffaf269170d7658cc0cd1ee322b601512b769446d3c8",
1919
strip_prefix = "protoc-gen-validate-{version}",
2020
urls = ["https://github.com/envoyproxy/protoc-gen-validate/archive/{version}.tar.gz"],
21-
last_updated = "2020-06-09",
21+
release_date = "2020-06-08",
2222
use_category = ["api"],
2323
),
2424
com_github_cncf_udpa = dict(
@@ -29,7 +29,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
2929
sha256 = "83a7dcc316d741031f34c0409021432b74a39c4811845a177133f02f948fe2d8",
3030
strip_prefix = "udpa-{version}",
3131
urls = ["https://github.com/cncf/udpa/archive/v{version}.tar.gz"],
32-
last_updated = "2020-09-23",
32+
release_date = "2020-06-29",
3333
use_category = ["api"],
3434
),
3535
com_github_openzipkin_zipkinapi = dict(
@@ -40,7 +40,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
4040
sha256 = "688c4fe170821dd589f36ec45aaadc03a618a40283bc1f97da8fa11686fc816b",
4141
strip_prefix = "zipkin-api-{version}",
4242
urls = ["https://github.com/openzipkin/zipkin-api/archive/{version}.tar.gz"],
43-
last_updated = "2020-09-23",
43+
release_date = "2019-08-23",
4444
use_category = ["api"],
4545
),
4646
com_google_googleapis = dict(
@@ -52,7 +52,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
5252
sha256 = "a45019af4d3290f02eaeb1ce10990166978c807cb33a9692141a076ba46d1405",
5353
strip_prefix = "googleapis-{version}",
5454
urls = ["https://github.com/googleapis/googleapis/archive/{version}.tar.gz"],
55-
last_updated = "2019-12-02",
55+
release_date = "2019-12-02",
5656
use_category = ["api"],
5757
),
5858
opencensus_proto = dict(
@@ -63,7 +63,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
6363
sha256 = "b7e13f0b4259e80c3070b583c2f39e53153085a6918718b1c710caf7037572b0",
6464
strip_prefix = "opencensus-proto-{version}/src",
6565
urls = ["https://github.com/census-instrumentation/opencensus-proto/archive/v{version}.tar.gz"],
66-
last_updated = "2020-06-20",
66+
release_date = "2020-07-21",
6767
use_category = ["api"],
6868
),
6969
prometheus_metrics_model = dict(
@@ -74,7 +74,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
7474
sha256 = "6748b42f6879ad4d045c71019d2512c94be3dd86f60965e9e31e44a3f464323e",
7575
strip_prefix = "client_model-{version}",
7676
urls = ["https://github.com/prometheus/client_model/archive/{version}.tar.gz"],
77-
last_updated = "2020-06-23",
77+
release_date = "2020-06-23",
7878
use_category = ["api"],
7979
),
8080
rules_proto = dict(
@@ -85,7 +85,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
8585
sha256 = "aa1ee19226f707d44bee44c720915199c20c84a23318bb0597ed4e5c873ccbd5",
8686
strip_prefix = "rules_proto-{version}",
8787
urls = ["https://github.com/bazelbuild/rules_proto/archive/{version}.tar.gz"],
88-
last_updated = "2020-08-17",
88+
release_date = "2020-08-17",
8989
use_category = ["api"],
9090
),
9191
)

bazel/repositories_extra.bzl

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _python_deps():
1414
# project_name = "PyYAML",
1515
# project_url = "https://github.com/yaml/pyyaml",
1616
# version = "5.3.1",
17-
# last_update = "2020-03-18"
17+
# release_date = "2020-03-18"
1818
# use_category = ["devtools"],
1919
# cpe = "cpe:2.3:a:pyyaml:pyyaml:*",
2020
)
@@ -26,14 +26,14 @@ def _python_deps():
2626
# project_name = "Jinja",
2727
# project_url = "http://palletsprojects.com/p/jinja",
2828
# version = "2.11.2",
29-
# last_update = "2020-04-13"
29+
# release_date = "2020-04-13"
3030
# use_category = ["test"],
3131
# cpe = "cpe:2.3:a:palletsprojects:jinja:*",
3232

3333
# project_name = "MarkupSafe",
3434
# project_url = "https://markupsafe.palletsprojects.com/en/1.1.x/",
3535
# version = "1.1.1",
36-
# last_update = "2019-02-23"
36+
# release_date = "2019-02-23"
3737
# use_category = ["test"],
3838
)
3939
pip3_import(
@@ -44,14 +44,14 @@ def _python_deps():
4444
# project_name = "Jinja",
4545
# project_url = "http://palletsprojects.com/p/jinja",
4646
# version = "2.11.2",
47-
# last_update = "2020-04-13"
47+
# release_date = "2020-04-13"
4848
# use_category = ["test"],
4949
# cpe = "cpe:2.3:a:palletsprojects:jinja:*",
5050

5151
# project_name = "MarkupSafe",
5252
# project_url = "https://markupsafe.palletsprojects.com/en/1.1.x/",
5353
# version = "1.1.1",
54-
# last_update = "2019-02-23"
54+
# release_date = "2019-02-23"
5555
# use_category = ["test"],
5656
)
5757
pip3_import(
@@ -62,7 +62,7 @@ def _python_deps():
6262
# project_name = "Clang",
6363
# project_url = "https://clang.llvm.org/",
6464
# version = "10.0.1",
65-
# last_update = "2020-07-21"
65+
# release_date = "2020-07-21"
6666
# use_category = ["devtools"],
6767
# cpe = "cpe:2.3:a:llvm:clang:*",
6868
)
@@ -74,7 +74,7 @@ def _python_deps():
7474
# project_name = "PyYAML",
7575
# project_url = "https://github.com/yaml/pyyaml",
7676
# version = "5.3.1",
77-
# last_update = "2020-03-18"
77+
# release_date = "2020-03-18"
7878
# use_category = ["docs"],
7979
# cpe = "cpe:2.3:a:pyyaml:pyyaml:*",
8080
)
@@ -86,14 +86,14 @@ def _python_deps():
8686
# project_name = "Apache Thrift",
8787
# project_url = "http://thrift.apache.org/",
8888
# version = "0.11.0",
89-
# last_update = "2017-12-07"
89+
# release_date = "2017-12-07"
9090
# use_category = ["test"],
9191
# cpe = "cpe:2.3:a:apache:thrift:*",
9292

9393
# project_name = "Six: Python 2 and 3 Compatibility Library",
9494
# project_url = "https://six.readthedocs.io/",
9595
# version = "1.15.0",
96-
# last_update = "2020-05-21"
96+
# release_date = "2020-05-21"
9797
# use_category = ["test"],
9898
)
9999

0 commit comments

Comments
 (0)