-
Notifications
You must be signed in to change notification settings - Fork 6k
Vulnerability Scanning on Third Party Deps #36506
Changes from 193 commits
695f6cc
fcb67e7
32b64f9
83f51a3
d656f82
54d1e47
e87e814
176a213
0b00a04
75a10e2
7148f07
1bfc9e0
4e306c1
e17b4af
5c17623
6a78cca
dc94c73
b565c52
a1c8e47
050dbdb
946b92f
25ac959
13717a0
f89ea8b
be44799
d40fc0d
05a7a19
5592b92
6d228e6
b6d23ad
6a03f90
f723115
95c6bdd
f92f213
6da3932
c8a0f3b
3aefb36
759e885
efbe91c
5e4b02e
7fb92fe
a8ff052
17075de
c407a8b
2dabc13
8bfb2a6
fe7d35c
29ad660
fa9e324
def0f52
d5ca5eb
45f989a
ede4227
d23ebb4
5cb1634
c8b0d58
45c1373
50c0a9a
745989c
f3838e9
d3326bd
d73e215
df7326d
207db30
e1d8aea
f3e6866
78078c7
11a163e
8a6e89b
68020c1
3766656
632ef2d
ec4c95b
9391606
14c04cc
6362bf5
8e5aa5f
892ac1f
5ea637e
4ba518e
7408287
23372ca
e08feb0
b59be01
cbd8812
8c00e92
1b4e0ad
5ce3863
b4a6e19
e07bd89
81d2288
710570b
847fa2a
5a73fe2
2d55449
c4f8849
cb34dfe
22026bd
8a11f03
b7792cf
130670e
42b6052
dc5e57c
aaef0c1
08ca59f
3efe999
10d0275
2cf9b7f
f03b057
7b4409d
e38baaa
e71c38d
b74707d
1552d23
2ee1412
1ba7453
23f1223
749dea4
6e16c5a
3df8b20
a0fcf9e
4bff454
0cdb05c
917413d
b001a01
7d424ae
8eca747
4167f08
b9b2e4c
89d6635
e2c9eb5
224c4f0
56db172
d4f67e0
caf8cbf
a5c7354
3e5ce2e
a54cc5e
edce7eb
e4508d6
418f063
edcb42c
f25c342
7d209da
7ed2727
80d38a4
5803dc5
2cacef0
d399071
5abec4e
f514274
e67a5e4
800451f
84da67a
ef45f10
47ae24d
3e844e4
a9bb384
7a48379
1a0d9e5
9f72f20
bbd6c37
170891e
7e39f62
c6aa604
29f343c
4a9ba21
e06c04f
4a848cf
369a31e
5a1ac42
e8a15b6
60d6986
dcf7413
b4c69b5
3d933f7
f907bfe
d93652a
2e6768b
102d8fc
1f1f199
9d93dc7
38e9ece
8f448cb
7f58db4
f8aa063
82498cb
7359c21
0af0bdd
0cb1ff8
c290fb7
90b85dc
b2295cd
c6c6313
039e5c5
70a9377
157f49e
4e304ba
ad81446
099d901
4309fce
02fa6b4
b1fa0b9
aa9f4f6
00bb405
83af3bd
1d674da
8b53b4a
0c651bf
c888420
6362cfd
b347320
c1ba498
aa420ac
d991bf6
f33c848
c49fbd5
e5b5b0f
f49ead5
cb1b4f2
8aff9ba
39a404e
20804a9
c94df9b
6c0ecfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Third party dependency scan | ||
on: | ||
# Only the default branch is supported. | ||
branch_protection_rule: | ||
branches: [ main ] | ||
schedule: | ||
- cron: "0 8 * * *" # runs daily at 08:00 | ||
|
||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
analysis: | ||
name: Third party dependency scan | ||
runs-on: ubuntu-latest | ||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
permissions: | ||
# Needed to upload the results to code-scanning dashboard. | ||
security-events: write | ||
actions: read | ||
contents: read | ||
|
||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
with: | ||
persist-credentials: false | ||
|
||
- name: setup python | ||
uses: actions/setup-python@98f2ad02fd48d057ee3b4d4f66525b231c3e52b6 | ||
with: | ||
python-version: '3.7.7' # install the python version needed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is failing https://github.com/flutter/engine/actions/runs/3566233289 |
||
|
||
- name: install dependency | ||
run: pip install git+https://github.com/psf/requests.git@4d394574f5555a8ddcc38f707e0c9f57f55d9a3b | ||
|
||
- name: execute py script | ||
run: python ci/deps_parser.py | ||
|
||
- name: parse deps_parser output.txt | ||
run: python ci/scan_flattened_deps.py | ||
|
||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF | ||
# format to the repository Actions tab. | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 | ||
with: | ||
name: SARIF file | ||
path: osvReport.sarif | ||
retention-days: 5 | ||
|
||
# Upload the results to GitHub's code scanning dashboard. | ||
- name: "Upload to code-scanning" | ||
uses: github/codeql-action/upload-sarif@a3a6c128d771b6b9bdebb1c9d0583ebd2728a108 | ||
with: | ||
sarif_file: osvReport.sarif |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -91,6 +91,115 @@ vars = { | |||||
|
||||||
# Setup Git hooks by default. | ||||||
"setup_githooks": True, | ||||||
|
||||||
# upstream URLs for third party dependencies, used in | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add instructions here that explain how to extend this list when a new dependency is added. Is there some way that people check whether the upstream repo URL is recognized by the vuln scanning service before landing a change?
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# determining common ancestor commit for vulnerability scanning | ||||||
# prefixed with "upstream_" in order to be identified by parsing tool | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"upstream_abseil-cpp": "https://github.com/abseil/abseil-cpp", | ||||||
"upstream_angle": "https://github.com/google/angle.git", | ||||||
"upstream_archive": "https://github.com/brendan-duncan/archive.git", | ||||||
"upstream_args": "https://github.com/dart-lang/args.git", | ||||||
"upstream_async": "https://github.com/dart-lang/async.git", | ||||||
"upstream_bazel_worker": "https://github.com/dart-lang/bazel_worker.git", | ||||||
"upstream_benchmark": "https://github.com/google/benchmark.git", | ||||||
"upstream_boolean_selector": "https://github.com/dart-lang/boolean_selector.git", | ||||||
"upstream_boringssl_gen": "https://github.com/dart-lang/boringssl_gen.git", | ||||||
"upstream_boringssl": "https://github.com/openssl/openssl", | ||||||
"upstream_browser_launcher": "https://github.com/dart-lang/browser_launcher.git", | ||||||
"upstream_buildroot": "https://github.com/flutter/buildroot.git", | ||||||
"upstream_cli_util": "https://github.com/dart-lang/cli_util.git", | ||||||
"upstream_clock": "https://github.com/dart-lang/clock.git", | ||||||
"upstream_collection": "https://github.com/dart-lang/collection.git", | ||||||
"upstream_colorama": "https://github.com/tartley/colorama", | ||||||
"upstream_convert": "https://github.com/dart-lang/convert.git", | ||||||
"upstream_crypto": "https://github.com/dart-lang/crypto.git", | ||||||
"upstream_csslib": "https://github.com/dart-lang/csslib.git", | ||||||
"upstream_dart_style": "https://github.com/dart-lang/dart_style.git", | ||||||
"upstream_dartdoc": "https://github.com/dart-lang/dartdoc.git", | ||||||
"upstream_equatable": "https://github.com/felangel/equatable.git", | ||||||
"upstream_ffi": "https://github.com/dart-lang/ffi.git", | ||||||
"upstream_file": "https://github.com/google/file.dart.git", | ||||||
"upstream_fixnum": "https://github.com/dart-lang/fixnum.git", | ||||||
"upstream_flatbuffers": "https://github.com/google/flatbuffers.git", | ||||||
"upstream_fontconfig": "https://gitlab.freedesktop.org/fontconfig/fontconfig.git", | ||||||
"upstream_freetype2": "https://gitlab.freedesktop.org/freetype/freetype.git", | ||||||
"upstream_gcloud": "https://github.com/dart-lang/gcloud.git", | ||||||
"upstream_glfw": "https://github.com/glfw/glfw.git", | ||||||
"upstream_glob": "https://github.com/dart-lang/glob.git", | ||||||
"upstream_googleapis": "https://github.com/google/googleapis.dart.git", | ||||||
"upstream_googletest": "https://github.com/google/googletest", | ||||||
"upstream_gtest-parallel": "https://github.com/google/gtest-parallel.git", | ||||||
"upstream_harfbuzz": "https://github.com/harfbuzz/harfbuzz.git", | ||||||
"upstream_html": "https://github.com/dart-lang/html.git", | ||||||
"upstream_http_multi_server": "https://github.com/dart-lang/http_multi_server.git", | ||||||
"upstream_http_parser": "https://github.com/dart-lang/http_parser.git", | ||||||
"upstream_http": "https://github.com/dart-lang/http.git", | ||||||
"upstream_icu": "https://github.com/unicode-org/icu.git", | ||||||
"upstream_imgui": "https://github.com/ocornut/imgui.git", | ||||||
"upstream_inja": "https://github.com/pantor/inja.git", | ||||||
"upstream_json": "https://github.com/nlohmann/json.git", | ||||||
"upstream_json_rpc_2": "https://github.com/dart-lang/json_rpc_2.git", | ||||||
"upstream_libcxx": "https://github.com/llvm-mirror/libcxx.git", | ||||||
"upstream_libcxxabi": "https://github.com/llvm-mirror/libcxxabi.git", | ||||||
"upstream_libexpat": "https://github.com/libexpat/libexpat.git", | ||||||
"upstream_libjpeg-turbo": "https://github.com/libjpeg-turbo/libjpeg-turbo.git", | ||||||
"upstream_libpng": "https://github.com/glennrp/libpng.git", | ||||||
"upstream_libtess2": "https://github.com/memononen/libtess2.git", | ||||||
"upstream_libwebp": "https://chromium.googlesource.com/webm/libwebp.git", | ||||||
"upstream_libxml": "https://gitlab.gnome.org/GNOME/libxml2.git", | ||||||
"upstream_linter": "https://github.com/dart-lang/linter.git", | ||||||
"upstream_logging": "https://github.com/dart-lang/logging.git", | ||||||
"upstream_markdown": "https://github.com/dart-lang/markdown.git", | ||||||
"upstream_matcher": "https://github.com/dart-lang/matcher.git", | ||||||
"upstream_mime": "https://github.com/dart-lang/mime.git", | ||||||
"upstream_mockito": "https://github.com/dart-lang/mockito.git", | ||||||
"upstream_oauth2": "https://github.com/dart-lang/oauth2.git", | ||||||
"upstream_ocmock": "https://github.com/erikdoe/ocmock.git", | ||||||
"upstream_package_config": "https://github.com/dart-lang/package_config.git", | ||||||
"upstream_packages": "https://github.com/flutter/packages.git", | ||||||
"upstream_path": "https://github.com/dart-lang/path.git", | ||||||
"upstream_platform": "https://github.com/google/platform.dart.git", | ||||||
"upstream_pool": "https://github.com/dart-lang/pool.git", | ||||||
"upstream_process_runner": "https://github.com/google/process_runner.git", | ||||||
"upstream_process": "https://github.com/google/process.dart.git", | ||||||
"upstream_protobuf": "https://github.com/google/protobuf.dart.git", | ||||||
"upstream_pub_semver": "https://github.com/dart-lang/pub_semver.git", | ||||||
"upstream_pub": "https://github.com/dart-lang/pub.git", | ||||||
"upstream_pyyaml": "https://github.com/yaml/pyyaml.git", | ||||||
"upstream_quiver-dart": "https://github.com/google/quiver-dart.git", | ||||||
"upstream_rapidjson": "https://github.com/Tencent/rapidjson.git", | ||||||
"upstream_root_certificates": "https://github.com/dart-lang/root_certificates.git", | ||||||
"upstream_sdk": "https://github.com/dart-lang/sdk.git", | ||||||
"upstream_shaderc": "https://github.com/google/shaderc.git", | ||||||
"upstream_shelf": "https://github.com/dart-lang/shelf.git", | ||||||
"upstream_skia": "https://skia.googlesource.com/skia.git", | ||||||
"upstream_source_map_stack_trace": "https://github.com/dart-lang/source_map_stack_trace.git", | ||||||
"upstream_source_maps": "https://github.com/dart-lang/source_maps.git", | ||||||
"upstream_source_span": "https://github.com/dart-lang/source_span.git", | ||||||
"upstream_sqlite": "https://github.com/sqlite/sqlite.git", | ||||||
"upstream_sse": "https://github.com/dart-lang/sse.git", | ||||||
"upstream_stack_trace": "https://github.com/dart-lang/stack_trace.git", | ||||||
"upstream_stream_channel": "https://github.com/dart-lang/stream_channel.git", | ||||||
"upstream_string_scanner": "https://github.com/dart-lang/string_scanner.git", | ||||||
"upstream_SwiftShader": "https://swiftshader.googlesource.com/SwiftShader.git", | ||||||
"upstream_term_glyph": "https://github.com/dart-lang/term_glyph.git", | ||||||
"upstream_test_reflective_loader": "https://github.com/dart-lang/test_reflective_loader.git", | ||||||
"upstream_test": "https://github.com/dart-lang/test.git", | ||||||
"upstream_tinygltf": "https://github.com/syoyo/tinygltf.git", | ||||||
"upstream_typed_data": "https://github.com/dart-lang/typed_data.git", | ||||||
"upstream_usage": "https://github.com/dart-lang/usage.git", | ||||||
"upstream_vector_math": "https://github.com/google/vector_math.dart.git", | ||||||
"upstream_Vulkan-Headers": "https://github.com/KhronosGroup/Vulkan-Headers.git", | ||||||
"upstream_VulkanMemoryAllocator": "https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git", | ||||||
"upstream_watcher": "https://github.com/dart-lang/watcher.git", | ||||||
"upstream_web_socket_channel": "https://github.com/dart-lang/web_socket_channel.git", | ||||||
"upstream_webdev": "https://github.com/dart-lang/webdev.git", | ||||||
"upstream_webkit_inspection_protocol": "https://github.com/google/webkit_inspection_protocol.dart.git", | ||||||
"upstream_wuffs-mirror-release-c": "https://github.com/google/wuffs-mirror-release-c.git", | ||||||
"upstream_yaml_edit": "https://github.com/dart-lang/yaml_edit.git", | ||||||
"upstream_yaml": "https://github.com/dart-lang/yaml.git", | ||||||
"upstream_yapf": "https://github.com/google/yapf.git", | ||||||
"upstream_zlib": "https://github.com/madler/zlib.git", | ||||||
} | ||||||
|
||||||
gclient_gn_args_file = 'src/third_party/dart/build/config/gclient_args.gni' | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Copyright 2013 The Flutter Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
# | ||
# Usage: deps_parser.py --deps <DEPS file> --output <flattened deps> | ||
# | ||
# This script parses the DEPS file, extracts the fully qualified dependencies | ||
|
@@ -12,11 +12,16 @@ | |
|
||
import argparse | ||
import os | ||
import re | ||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import sys | ||
|
||
SCRIPT_DIR = os.path.dirname(sys.argv[0]) | ||
CHECKOUT_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) | ||
|
||
CHROMIUM_README_FILE = 'third_party/accessibility/README.md' | ||
CHROMIUM_README_COMMIT_LINE = 4 # the fifth line will always contain the commit hash | ||
CHROMIUM = 'https://chromium.googlesource.com/chromium/src' | ||
|
||
|
||
# Used in parsing the DEPS file. | ||
class VarImpl: | ||
|
@@ -55,15 +60,33 @@ def parse_deps_file(deps_file): | |
# Extract the deps and filter. | ||
deps = local_scope.get('deps', {}) | ||
filtered_deps = [] | ||
for val in deps.values(): | ||
for _, dep in deps.items(): | ||
# We currently do not support packages or cipd which are represented | ||
# as dictionaries. | ||
if isinstance(val, str): | ||
filtered_deps.append(val) | ||
|
||
if isinstance(dep, str): | ||
print(dep) | ||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
filtered_deps.append(dep) | ||
return filtered_deps | ||
|
||
|
||
def parse_readme(deps): | ||
""" | ||
Opens the Flutter Accessibility Library README and uses the commit hash | ||
found in the README to check for viulnerabilities. | ||
The commit hash in this README will always be in the same format | ||
""" | ||
file_path = os.path.join(CHECKOUT_ROOT, CHROMIUM_README_FILE) | ||
file = open(file_path) | ||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# read the content of the file opened | ||
content = file.readlines() | ||
commit_line = content[CHROMIUM_README_COMMIT_LINE] | ||
print('commit line: ' + commit_line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this print needed? |
||
commit = re.search(r'(?<=\[).*(?=\])', commit_line) | ||
print(CHROMIUM + '@' + commit.group()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. |
||
deps.append(CHROMIUM + '@' + commit.group()) | ||
return deps | ||
|
||
|
||
def write_manifest(deps, manifest_file): | ||
print('\n'.join(sorted(deps))) | ||
with open(manifest_file, 'w') as manifest: | ||
|
@@ -97,6 +120,7 @@ def parse_args(args): | |
def main(argv): | ||
args = parse_args(argv) | ||
deps = parse_deps_file(args.deps) | ||
deps = parse_readme(deps) | ||
write_manifest(deps, args.output) | ||
return 0 | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,95 @@ | ||||||
#!/usr/bin/env python3 | ||||||
# | ||||||
# Copyright 2013 The Flutter Authors. All rights reserved. | ||||||
# Use of this source code is governed by a BSD-style license that can be | ||||||
# found in the LICENSE file. | ||||||
|
||||||
import os | ||||||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
import sys | ||||||
import unittest | ||||||
from deps_parser import VarImpl | ||||||
|
||||||
SCRIPT_DIR = os.path.dirname(sys.argv[0]) | ||||||
CHECKOUT_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) | ||||||
DEPS = os.path.join(CHECKOUT_ROOT, 'DEPS') | ||||||
UPSTREAM_PREFIX = 'upstream_' | ||||||
|
||||||
|
||||||
class TestDepsParserMethods(unittest.TestCase): | ||||||
|
||||||
# extract both mirrored dep names and URLs & | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
# upstream names and URLs from DEPs file | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
def setUp(self): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it needs to be setUp for the python unittest framework There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lower-camel-case is inconsistent with the rest of the file |
||||||
with open(DEPS) as file: | ||||||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
local_scope_upstream = {} | ||||||
global_scope_upstream = {'Var': lambda x: x} # dummy lambda | ||||||
# Read the content. | ||||||
with open(DEPS, 'r') as file: | ||||||
deps_content = file.read() | ||||||
|
||||||
# Eval the content. | ||||||
exec(deps_content, global_scope_upstream, local_scope_upstream) | ||||||
|
||||||
# Extract the upstream URLs | ||||||
# vars contains more than just upstream URLs | ||||||
# however the upstream URLs are prefixed with 'upstream_' | ||||||
upstream = local_scope_upstream.get('vars') | ||||||
self.upstream_urls = upstream | ||||||
|
||||||
local_scope_mirror = {} | ||||||
var = VarImpl(local_scope_mirror) | ||||||
global_scope_mirror = { | ||||||
'Var': var.lookup, | ||||||
'deps_os': {}, | ||||||
} | ||||||
|
||||||
# Eval the content. | ||||||
exec(deps_content, global_scope_mirror, local_scope_mirror) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why this needs to be done twice. Could the code from lines 36-37 be moved after here (using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this resolved? |
||||||
|
||||||
# Extract the deps and filter. | ||||||
deps = local_scope_mirror.get('deps', {}) | ||||||
filtered_deps = [] | ||||||
for _, dep in deps.items(): | ||||||
# We currently do not support packages or cipd which are represented | ||||||
# as dictionaries. | ||||||
if isinstance(dep, str): | ||||||
filtered_deps.append(dep) | ||||||
|
||||||
self.deps = filtered_deps | ||||||
|
||||||
def test_each_dep_has_upstream_url(self): | ||||||
# for each DEP in the deps file, check for an associated upstream URL in deps file | ||||||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
for dep in self.deps: | ||||||
dep_repo = dep.split('@')[0] | ||||||
dep_name = dep_repo.split('/')[-1].split('.')[0] | ||||||
# vulkan-deps and khronos do not have one upstream URL | ||||||
# all other deps should have an associated upstream URL for vuln scanning purposes | ||||||
if dep_name not in ('vulkan-deps', 'khronos'): | ||||||
# add the prefix on the dep name when searching for the upstream entry | ||||||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
self.assertTrue( | ||||||
UPSTREAM_PREFIX + dep_name in self.upstream_urls, | ||||||
msg=dep_name + ' not found in upstream URL list' | ||||||
) | ||||||
|
||||||
def test_each_upstream_url_has_dep(self): | ||||||
|
||||||
sealesj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# parse DEPS into dependency names | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
deps_names = [] | ||||||
for dep in self.deps: | ||||||
dep_repo = dep.split('@')[0] | ||||||
dep_name = dep_repo.split('/')[-1].split('.')[0] | ||||||
deps_names.append(dep_name) | ||||||
|
||||||
# for each upstream URL dep, check it exists as in DEPS | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
for upsream_dep in self.upstream_urls: | ||||||
# only test on upstream deps in vars section which start with the upstream prefix | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if upsream_dep.startswith(UPSTREAM_PREFIX): | ||||||
# strip the prefix to check that it has a corresponding dependency in the DEPS file | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
self.assertTrue( | ||||||
upsream_dep[len(UPSTREAM_PREFIX):] in deps_names, | ||||||
msg=upsream_dep + ' from upstream list not found in DEPS' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this also need to check the other way around? That is, that there is an entry in Also, ideally, the error message would explain how to fix the problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I test the other way around in the above method |
||||||
) | ||||||
|
||||||
|
||||||
if __name__ == '__main__': | ||||||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if/when this fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this workflow is not connected back to the presubmit checks, failure on the workflow will amount to just failure within the actions tab and notify the person who triggered it. If desired, I could connect to a presubmit check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "Notify the person who triggered it" mean? I'd prefer a notification, and not anything that could block developers, like a presubmit check. The new test added below should be the only new thing that engine team members need to pay attention to unless there's a vulnerability detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a presubmit check and does not block developers. The user who opened the PR will receive an email if the vulnerability scanning has failed.