Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Vulnerability Scanning on Third Party Deps #36506

Merged
merged 225 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 193 commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
695f6cc
initial flatten deps scan
sealesj May 13, 2022
fcb67e7
Merge branch 'main' of github.com:sealesj/engine
sealesj May 13, 2022
32b64f9
Merge branch 'flutter:main' into deps-parse-workflow
sealesj May 13, 2022
83f51a3
move 3rd party scan to separate action
sealesj May 13, 2022
d656f82
Merge branch 'deps-parse-workflow' of github.com:sealesj/engine into …
sealesj May 13, 2022
54d1e47
allow fork to run
sealesj May 13, 2022
e87e814
install requests
sealesj May 13, 2022
176a213
use packages
sealesj May 13, 2022
0b00a04
pip install
sealesj May 13, 2022
75a10e2
rename
sealesj May 13, 2022
7148f07
Merge branch 'flutter:main' into main
sealesj May 16, 2022
1bfc9e0
conditional vuln report
sealesj May 23, 2022
4e306c1
trailing whitespace
sealesj May 23, 2022
e17b4af
trailing whitespace
sealesj May 23, 2022
5c17623
Merge branch 'flutter:main' into main
sealesj May 26, 2022
6a78cca
detailed print
sealesj May 26, 2022
dc94c73
add testing file
sealesj May 27, 2022
b565c52
Merge branch 'main' of github.com:sealesj/engine
sealesj May 27, 2022
a1c8e47
Merge branch 'flutter:main' into main
sealesj May 27, 2022
050dbdb
add upload test sarif
sealesj May 27, 2022
946b92f
Merge branch 'main' of github.com:sealesj/engine
sealesj May 27, 2022
25ac959
results sarif
sealesj May 27, 2022
13717a0
move sarif
sealesj May 27, 2022
f89ea8b
upload modified sarif
sealesj May 30, 2022
be44799
test flow
sealesj May 31, 2022
d40fc0d
test with results.sarif
sealesj May 31, 2022
05a7a19
formatting
sealesj May 31, 2022
5592b92
test naming convention
sealesj May 31, 2022
6d228e6
description with text in artifactLocation
sealesj May 31, 2022
b6d23ad
don't use locations
sealesj May 31, 2022
6a03f90
use template sarif
sealesj May 31, 2022
f723115
just use template
sealesj May 31, 2022
95c6bdd
add one field mod
sealesj May 31, 2022
f92f213
add another field mod
sealesj May 31, 2022
6da3932
use actual osvReport
sealesj May 31, 2022
c8a0f3b
add field
sealesj May 31, 2022
3aefb36
add field
sealesj May 31, 2022
759e885
test
sealesj Jun 1, 2022
efbe91c
no information uri
sealesj Jun 1, 2022
5e4b02e
no information uri
sealesj Jun 1, 2022
7fb92fe
add name
sealesj Jun 1, 2022
a8ff052
template NA data for results
sealesj Jun 1, 2022
17075de
back to minimal template
sealesj Jun 1, 2022
c407a8b
dynamic rules
sealesj Jun 1, 2022
2dabc13
template update
sealesj Jun 1, 2022
8bfb2a6
no results
sealesj Jun 1, 2022
fe7d35c
only use template
sealesj Jun 1, 2022
29ad660
test
sealesj Jun 2, 2022
fa9e324
new test
sealesj Jun 2, 2022
def0f52
new test
sealesj Jun 2, 2022
d5ca5eb
add back locations
sealesj Jun 2, 2022
45f989a
descriptive fields
sealesj Jun 2, 2022
ede4227
test
sealesj Jun 2, 2022
d23ebb4
use package name
sealesj Jun 2, 2022
5cb1634
variable commit hash
sealesj Jun 2, 2022
c8b0d58
add chromium accessibility readme support
sealesj Jun 3, 2022
45c1373
use batch query test
sealesj Jun 8, 2022
50c0a9a
clean up
sealesj Jun 8, 2022
745989c
use variables for sarif template
sealesj Jun 9, 2022
f3838e9
initial automating ancestor commit
sealesj Aug 2, 2022
d3326bd
allow for workflow on testing
sealesj Aug 2, 2022
d73e215
install gitpython in workflow
sealesj Aug 2, 2022
df7326d
wrap in try
sealesj Aug 2, 2022
207db30
expand try
sealesj Aug 2, 2022
e1d8aea
check commit is not none
sealesj Aug 2, 2022
f3e6866
quiet clone
sealesj Aug 2, 2022
78078c7
fix commit newline
sealesj Aug 3, 2022
11a163e
proper print for failed deps
sealesj Aug 3, 2022
8a6e89b
remove gitpython
sealesj Aug 3, 2022
68020c1
Merge branch 'main' of github.com:sealesj/engine into osv-scan
sealesj Aug 3, 2022
3766656
Merge branch 'flutter:main' into osv-scan
sealesj Aug 3, 2022
632ef2d
remove import
sealesj Aug 3, 2022
ec4c95b
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Aug 3, 2022
9391606
Merge branch 'flutter:main' into osv-scan
sealesj Aug 4, 2022
14c04cc
Merge branch 'flutter:main' into osv-scan
sealesj Aug 5, 2022
6362bf5
fix origin source
sealesj Aug 5, 2022
8e5aa5f
remove .dart from dep names
sealesj Aug 5, 2022
892ac1f
Merge branch 'flutter:main' into osv-scan
sealesj Aug 15, 2022
5ea637e
update dep
sealesj Aug 15, 2022
4ba518e
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Aug 15, 2022
7408287
typo
sealesj Aug 15, 2022
23372ca
update
sealesj Aug 15, 2022
e08feb0
clone into controlled name repo now
sealesj Aug 16, 2022
b59be01
fix github upstream clone url
sealesj Aug 16, 2022
cbd8812
test CVE finding
sealesj Aug 16, 2022
8c00e92
use templated rule and result
sealesj Aug 16, 2022
1b4e0ad
typo
sealesj Aug 16, 2022
5ce3863
remove test CVE
sealesj Aug 16, 2022
b4a6e19
add link straight to OSV DB
sealesj Aug 16, 2022
e07bd89
comments
sealesj Aug 17, 2022
81d2288
use os mkdir
sealesj Aug 18, 2022
710570b
Merge branch 'flutter:main' into osv-scan
sealesj Aug 22, 2022
847fa2a
check time of pinned commit
sealesj Aug 22, 2022
5a73fe2
Merge pull request #2 from sealesj/dep-age-threshold
sealesj Aug 22, 2022
2d55449
quiet git
sealesj Aug 23, 2022
c4f8849
Merge branch 'flutter:main' into osv-scan
sealesj Aug 23, 2022
cb34dfe
Merge branch 'flutter:main' into osv-scan
sealesj Aug 24, 2022
22026bd
Merge branch 'flutter:main' into osv-scan
sealesj Aug 26, 2022
8a11f03
Merge branch 'flutter:main' into osv-scan
sealesj Aug 29, 2022
b7792cf
print osv api query results if vulns found
sealesj Aug 29, 2022
130670e
Merge pull request #3 from sealesj/show-vuln-query-results
sealesj Aug 29, 2022
42b6052
move upstream mapping into DEPS file
sealesj Sep 1, 2022
dc5e57c
Merge pull request #4 from sealesj/upstream-urls-to-deps
sealesj Sep 1, 2022
aaef0c1
Merge branch 'flutter:main' into osv-scan
sealesj Sep 1, 2022
08ca59f
Merge branch 'flutter:main' into osv-scan
sealesj Sep 2, 2022
3efe999
Merge branch 'flutter:main' into osv-scan
sealesj Sep 6, 2022
10d0275
add testing for DEPS file
sealesj Sep 7, 2022
2cf9b7f
Merge pull request #5 from sealesj/test-osv-scan
sealesj Sep 7, 2022
f03b057
Merge branch 'flutter:main' into osv-scan
sealesj Sep 7, 2022
7b4409d
add khronos exception
sealesj Sep 7, 2022
e38baaa
Merge pull request #6 from sealesj/test-osv-scan
sealesj Sep 7, 2022
e71c38d
Merge branch 'flutter:main' into osv-scan
sealesj Sep 7, 2022
b74707d
add basic ancestor commit test
sealesj Sep 7, 2022
1552d23
Merge branch 'flutter:main' into osv-scan
sealesj Sep 7, 2022
2ee1412
Merge pull request #7 from sealesj/scan-deps-tests
sealesj Sep 7, 2022
1ba7453
Merge branch 'flutter:main' into osv-scan
sealesj Sep 8, 2022
23f1223
no vulns message
sealesj Sep 8, 2022
749dea4
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Sep 8, 2022
6e16c5a
do not produce empty sarif
sealesj Sep 8, 2022
3df8b20
add yaml
sealesj Sep 15, 2022
a0fcf9e
remove unused python dep
sealesj Sep 19, 2022
4bff454
no change?
sealesj Sep 19, 2022
0cdb05c
no more print, causing recipe issues
sealesj Sep 19, 2022
917413d
string test
sealesj Sep 19, 2022
b001a01
string test
sealesj Sep 19, 2022
7d424ae
no more fstrings
sealesj Sep 19, 2022
8eca747
convert to .format
sealesj Sep 19, 2022
4167f08
syntax
sealesj Sep 19, 2022
b9b2e4c
remove unused dep
sealesj Sep 19, 2022
89d6635
test
sealesj Sep 19, 2022
e2c9eb5
switch test script
sealesj Sep 19, 2022
224c4f0
no encoding
sealesj Sep 19, 2022
56db172
add back test
sealesj Sep 19, 2022
d4f67e0
typo
sealesj Sep 19, 2022
caf8cbf
remove scan flat deps tests again
sealesj Sep 19, 2022
a5c7354
update
sealesj Sep 21, 2022
3e5ce2e
fix tests
sealesj Sep 21, 2022
a54cc5e
Merge branch 'main' of github.com:sealesj/engine into osv-scan
sealesj Sep 22, 2022
edce7eb
Merge branch 'osv-scan' of github.com:sealesj/engine into connect-dep…
sealesj Sep 22, 2022
e4508d6
typo
sealesj Sep 22, 2022
418f063
newline
sealesj Sep 22, 2022
edcb42c
Merge pull request #11 from sealesj/connect-deps-test
sealesj Sep 22, 2022
f25c342
use checkout dir
sealesj Sep 22, 2022
7d209da
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Sep 22, 2022
7ed2727
prefix
sealesj Sep 23, 2022
80d38a4
update to use prefix
sealesj Sep 23, 2022
5803dc5
Merge pull request #12 from sealesj/reformat-deps
sealesj Sep 23, 2022
2cacef0
lint
sealesj Sep 26, 2022
d399071
runhook attempt
sealesj Sep 26, 2022
5abec4e
lint
sealesj Sep 26, 2022
f514274
lint
sealesj Sep 26, 2022
e67a5e4
lint
sealesj Sep 26, 2022
800451f
lint
sealesj Sep 26, 2022
84da67a
no license blurb
sealesj Sep 26, 2022
ef45f10
cleanup
sealesj Sep 27, 2022
47ae24d
enable for main
sealesj Sep 27, 2022
3e844e4
do not raise error
sealesj Sep 27, 2022
a9bb384
run on branch
sealesj Sep 27, 2022
7a48379
data indentation
sealesj Sep 28, 2022
1a0d9e5
check file existence
sealesj Sep 28, 2022
9f72f20
workflow updates
sealesj Sep 28, 2022
bbd6c37
add push for testing
sealesj Sep 28, 2022
170891e
syntax
sealesj Sep 28, 2022
7e39f62
workflow test
sealesj Sep 28, 2022
c6aa604
test github action
sealesj Sep 29, 2022
29f343c
syntax
sealesj Sep 29, 2022
4a9ba21
allow empty report
sealesj Sep 29, 2022
e06c04f
update cron
sealesj Sep 29, 2022
4a848cf
pin hash
sealesj Sep 29, 2022
369a31e
newline
sealesj Sep 29, 2022
5a1ac42
sort by key with prefix omitted
sealesj Sep 29, 2022
e8a15b6
alphabetize, copyright header
sealesj Sep 29, 2022
60d6986
pylint tests
sealesj Sep 30, 2022
dcf7413
lint
sealesj Sep 30, 2022
b4c69b5
lint
sealesj Sep 30, 2022
3d933f7
trailing whitespace?
sealesj Sep 30, 2022
f907bfe
lint
sealesj Sep 30, 2022
d93652a
update
sealesj Sep 30, 2022
2e6768b
get error types
sealesj Sep 30, 2022
102d8fc
allow test
sealesj Sep 30, 2022
1f1f199
use output
sealesj Sep 30, 2022
9d93dc7
Merge remote-tracking branch 'upstream/master' into osv-scan
sealesj Sep 30, 2022
38e9ece
only main branch
sealesj Sep 30, 2022
8f448cb
licenses check
sealesj Sep 30, 2022
7f58db4
results.sarif
sealesj Sep 30, 2022
f8aa063
revert
sealesj Sep 30, 2022
82498cb
license updates
sealesj Sep 30, 2022
7359c21
add upstream
sealesj Oct 5, 2022
0af0bdd
replace Requests library with urllib, remove pylint wrapper
sealesj Oct 7, 2022
0cb1ff8
lint
sealesj Oct 7, 2022
c290fb7
undo license
sealesj Oct 7, 2022
90b85dc
clone test nit
sealesj Oct 7, 2022
b2295cd
isinstance
sealesj Oct 10, 2022
c6c6313
DEPS formatting
sealesj Oct 25, 2022
039e5c5
use subprocess.check_output
sealesj Oct 26, 2022
70a9377
lint
sealesj Oct 26, 2022
157f49e
lint
sealesj Oct 26, 2022
4e304ba
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Oct 26, 2022
ad81446
Merge branch 'flutter:main' into osv-scan
sealesj Oct 26, 2022
099d901
review syntax from comments
sealesj Oct 26, 2022
4309fce
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Oct 26, 2022
02fa6b4
remove line
sealesj Oct 27, 2022
b1fa0b9
more description in error
sealesj Oct 27, 2022
aa9f4f6
lint
sealesj Oct 27, 2022
00bb405
fix checkout path
sealesj Oct 27, 2022
83af3bd
remove duplicate eval
sealesj Oct 27, 2022
1d674da
lint
sealesj Oct 27, 2022
8b53b4a
lint
sealesj Oct 31, 2022
0c651bf
lint
sealesj Oct 31, 2022
c888420
clone-test mkdir and cleanup
sealesj Oct 31, 2022
6362cfd
use shutil.rmtree for non-empty dir
sealesj Oct 31, 2022
b347320
lint
sealesj Oct 31, 2022
c1ba498
linting
sealesj Oct 31, 2022
aa420ac
linting
sealesj Oct 31, 2022
d991bf6
var name
sealesj Nov 1, 2022
f33c848
Update ci/deps_parser_tests.py
sealesj Nov 10, 2022
c49fbd5
Update ci/deps_parser_tests.py
sealesj Nov 10, 2022
e5b5b0f
more description
sealesj Nov 10, 2022
f49ead5
lint
sealesj Nov 15, 2022
cb1b4f2
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj Nov 15, 2022
8aff9ba
refactor deps file parsing
sealesj Nov 22, 2022
39a404e
early return
sealesj Nov 23, 2022
20804a9
Merge branch 'flutter:main' into osv-scan
sealesj Nov 23, 2022
c94df9b
lint
sealesj Nov 23, 2022
6c0ecfe
Merge branch 'osv-scan' of https://github.com/sealesj/engine into osv…
sealesj Nov 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/third_party_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Third party dependency scan
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- 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
109 changes: 109 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,115 @@ vars = {

# Setup Git hooks by default.
"setup_githooks": True,

# upstream URLs for third party dependencies, used in
Copy link
Member

Choose a reason for hiding this comment

The 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?

# determining common ancestor commit for vulnerability scanning
# prefixed with "upstream_" in order to be identified by parsing tool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# prefixed with "upstream_" in order to be identified by parsing tool
# prefixed with "upstream_" in order to be identified by parsing tool.

"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'
Expand Down
34 changes: 29 additions & 5 deletions ci/deps_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,11 +12,16 @@

import argparse
import os
import re
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:
Expand Down Expand Up @@ -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)
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)
# read the content of the file opened
content = file.readlines()
commit_line = content[CHROMIUM_README_COMMIT_LINE]
print('commit line: ' + commit_line)
Copy link
Member

Choose a reason for hiding this comment

The 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())
Copy link
Member

Choose a reason for hiding this comment

The 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:
Expand Down Expand Up @@ -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

Expand Down
95 changes: 95 additions & 0 deletions ci/deps_parser_tests.py
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
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 &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# extract both mirrored dep names and URLs &
# Extract both mirrored dep names and URLs &

# upstream names and URLs from DEPs file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# upstream names and URLs from DEPs file
# upstream names and URLs from DEPs file.

def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def setUp(self):
def setup(self):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs to be setUp for the python unittest framework

Copy link
Member

Choose a reason for hiding this comment

The 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:
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)
Copy link
Member

Choose a reason for hiding this comment

The 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 local_scope_mirror instead of local_scope_upstream), and the first invocation of eval removed?

Copy link
Member

Choose a reason for hiding this comment

The 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
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
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):

# parse DEPS into dependency names
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# parse DEPS into dependency names
# Parse DEPS into dependency names.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# for each upstream URL dep, check it exists as in DEPS
# For each upstream URL dep, check it exists as in DEPS.

for upsream_dep in self.upstream_urls:
# only test on upstream deps in vars section which start with the upstream prefix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# only test on upstream deps in vars section which start with the upstream prefix
# Only test on upstream deps in vars section which start with the upstream prefix.

if upsream_dep.startswith(UPSTREAM_PREFIX):
# strip the prefix to check that it has a corresponding dependency in the DEPS file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# strip the prefix to check that it has a corresponding dependency in the DEPS file
# Strip the prefix to check that it has a corresponding dependency in the DEPS file.

self.assertTrue(
upsream_dep[len(UPSTREAM_PREFIX):] in deps_names,
msg=upsream_dep + ' from upstream list not found in DEPS'
Copy link
Member

Choose a reason for hiding this comment

The 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 deps_names for which we haven't listed an upstream?

Also, ideally, the error message would explain how to fix the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I test the other way around in the above method test_each_dep_has_upstream_url

)


if __name__ == '__main__':
unittest.main()
Loading