This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Vulnerability Scanning on Third Party Deps #36506
Merged
Merged
Changes from all commits
Commits
Show all changes
225 commits
Select commit
Hold shift + click to select a range
695f6cc
initial flatten deps scan
sealesj fcb67e7
Merge branch 'main' of github.com:sealesj/engine
sealesj 32b64f9
Merge branch 'flutter:main' into deps-parse-workflow
sealesj 83f51a3
move 3rd party scan to separate action
sealesj d656f82
Merge branch 'deps-parse-workflow' of github.com:sealesj/engine into …
sealesj 54d1e47
allow fork to run
sealesj e87e814
install requests
sealesj 176a213
use packages
sealesj 0b00a04
pip install
sealesj 75a10e2
rename
sealesj 7148f07
Merge branch 'flutter:main' into main
sealesj 1bfc9e0
conditional vuln report
sealesj 4e306c1
trailing whitespace
sealesj e17b4af
trailing whitespace
sealesj 5c17623
Merge branch 'flutter:main' into main
sealesj 6a78cca
detailed print
sealesj dc94c73
add testing file
sealesj b565c52
Merge branch 'main' of github.com:sealesj/engine
sealesj a1c8e47
Merge branch 'flutter:main' into main
sealesj 050dbdb
add upload test sarif
sealesj 946b92f
Merge branch 'main' of github.com:sealesj/engine
sealesj 25ac959
results sarif
sealesj 13717a0
move sarif
sealesj f89ea8b
upload modified sarif
sealesj be44799
test flow
sealesj d40fc0d
test with results.sarif
sealesj 05a7a19
formatting
sealesj 5592b92
test naming convention
sealesj 6d228e6
description with text in artifactLocation
sealesj b6d23ad
don't use locations
sealesj 6a03f90
use template sarif
sealesj f723115
just use template
sealesj 95c6bdd
add one field mod
sealesj f92f213
add another field mod
sealesj 6da3932
use actual osvReport
sealesj c8a0f3b
add field
sealesj 3aefb36
add field
sealesj 759e885
test
sealesj efbe91c
no information uri
sealesj 5e4b02e
no information uri
sealesj 7fb92fe
add name
sealesj a8ff052
template NA data for results
sealesj 17075de
back to minimal template
sealesj c407a8b
dynamic rules
sealesj 2dabc13
template update
sealesj 8bfb2a6
no results
sealesj fe7d35c
only use template
sealesj 29ad660
test
sealesj fa9e324
new test
sealesj def0f52
new test
sealesj d5ca5eb
add back locations
sealesj 45f989a
descriptive fields
sealesj ede4227
test
sealesj d23ebb4
use package name
sealesj 5cb1634
variable commit hash
sealesj c8b0d58
add chromium accessibility readme support
sealesj 45c1373
use batch query test
sealesj 50c0a9a
clean up
sealesj 745989c
use variables for sarif template
sealesj f3838e9
initial automating ancestor commit
sealesj d3326bd
allow for workflow on testing
sealesj d73e215
install gitpython in workflow
sealesj df7326d
wrap in try
sealesj 207db30
expand try
sealesj e1d8aea
check commit is not none
sealesj f3e6866
quiet clone
sealesj 78078c7
fix commit newline
sealesj 11a163e
proper print for failed deps
sealesj 8a6e89b
remove gitpython
sealesj 68020c1
Merge branch 'main' of github.com:sealesj/engine into osv-scan
sealesj 3766656
Merge branch 'flutter:main' into osv-scan
sealesj 632ef2d
remove import
sealesj ec4c95b
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 9391606
Merge branch 'flutter:main' into osv-scan
sealesj 14c04cc
Merge branch 'flutter:main' into osv-scan
sealesj 6362bf5
fix origin source
sealesj 8e5aa5f
remove .dart from dep names
sealesj 892ac1f
Merge branch 'flutter:main' into osv-scan
sealesj 5ea637e
update dep
sealesj 4ba518e
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 7408287
typo
sealesj 23372ca
update
sealesj e08feb0
clone into controlled name repo now
sealesj b59be01
fix github upstream clone url
sealesj cbd8812
test CVE finding
sealesj 8c00e92
use templated rule and result
sealesj 1b4e0ad
typo
sealesj 5ce3863
remove test CVE
sealesj b4a6e19
add link straight to OSV DB
sealesj e07bd89
comments
sealesj 81d2288
use os mkdir
sealesj 710570b
Merge branch 'flutter:main' into osv-scan
sealesj 847fa2a
check time of pinned commit
sealesj 5a73fe2
Merge pull request #2 from sealesj/dep-age-threshold
sealesj 2d55449
quiet git
sealesj c4f8849
Merge branch 'flutter:main' into osv-scan
sealesj cb34dfe
Merge branch 'flutter:main' into osv-scan
sealesj 22026bd
Merge branch 'flutter:main' into osv-scan
sealesj 8a11f03
Merge branch 'flutter:main' into osv-scan
sealesj b7792cf
print osv api query results if vulns found
sealesj 130670e
Merge pull request #3 from sealesj/show-vuln-query-results
sealesj 42b6052
move upstream mapping into DEPS file
sealesj dc5e57c
Merge pull request #4 from sealesj/upstream-urls-to-deps
sealesj aaef0c1
Merge branch 'flutter:main' into osv-scan
sealesj 08ca59f
Merge branch 'flutter:main' into osv-scan
sealesj 3efe999
Merge branch 'flutter:main' into osv-scan
sealesj 10d0275
add testing for DEPS file
sealesj 2cf9b7f
Merge pull request #5 from sealesj/test-osv-scan
sealesj f03b057
Merge branch 'flutter:main' into osv-scan
sealesj 7b4409d
add khronos exception
sealesj e38baaa
Merge pull request #6 from sealesj/test-osv-scan
sealesj e71c38d
Merge branch 'flutter:main' into osv-scan
sealesj b74707d
add basic ancestor commit test
sealesj 1552d23
Merge branch 'flutter:main' into osv-scan
sealesj 2ee1412
Merge pull request #7 from sealesj/scan-deps-tests
sealesj 1ba7453
Merge branch 'flutter:main' into osv-scan
sealesj 23f1223
no vulns message
sealesj 749dea4
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 6e16c5a
do not produce empty sarif
sealesj 3df8b20
add yaml
sealesj a0fcf9e
remove unused python dep
sealesj 4bff454
no change?
sealesj 0cdb05c
no more print, causing recipe issues
sealesj 917413d
string test
sealesj b001a01
string test
sealesj 7d424ae
no more fstrings
sealesj 8eca747
convert to .format
sealesj 4167f08
syntax
sealesj b9b2e4c
remove unused dep
sealesj 89d6635
test
sealesj e2c9eb5
switch test script
sealesj 224c4f0
no encoding
sealesj 56db172
add back test
sealesj d4f67e0
typo
sealesj caf8cbf
remove scan flat deps tests again
sealesj a5c7354
update
sealesj 3e5ce2e
fix tests
sealesj a54cc5e
Merge branch 'main' of github.com:sealesj/engine into osv-scan
sealesj edce7eb
Merge branch 'osv-scan' of github.com:sealesj/engine into connect-dep…
sealesj e4508d6
typo
sealesj 418f063
newline
sealesj edcb42c
Merge pull request #11 from sealesj/connect-deps-test
sealesj f25c342
use checkout dir
sealesj 7d209da
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 7ed2727
prefix
sealesj 80d38a4
update to use prefix
sealesj 5803dc5
Merge pull request #12 from sealesj/reformat-deps
sealesj 2cacef0
lint
sealesj d399071
runhook attempt
sealesj 5abec4e
lint
sealesj f514274
lint
sealesj e67a5e4
lint
sealesj 800451f
lint
sealesj 84da67a
no license blurb
sealesj ef45f10
cleanup
sealesj 47ae24d
enable for main
sealesj 3e844e4
do not raise error
sealesj a9bb384
run on branch
sealesj 7a48379
data indentation
sealesj 1a0d9e5
check file existence
sealesj 9f72f20
workflow updates
sealesj bbd6c37
add push for testing
sealesj 170891e
syntax
sealesj 7e39f62
workflow test
sealesj c6aa604
test github action
sealesj 29f343c
syntax
sealesj 4a9ba21
allow empty report
sealesj e06c04f
update cron
sealesj 4a848cf
pin hash
sealesj 369a31e
newline
sealesj 5a1ac42
sort by key with prefix omitted
sealesj e8a15b6
alphabetize, copyright header
sealesj 60d6986
pylint tests
sealesj dcf7413
lint
sealesj b4c69b5
lint
sealesj 3d933f7
trailing whitespace?
sealesj f907bfe
lint
sealesj d93652a
update
sealesj 2e6768b
get error types
sealesj 102d8fc
allow test
sealesj 1f1f199
use output
sealesj 9d93dc7
Merge remote-tracking branch 'upstream/master' into osv-scan
sealesj 38e9ece
only main branch
sealesj 8f448cb
licenses check
sealesj 7f58db4
results.sarif
sealesj f8aa063
revert
sealesj 82498cb
license updates
sealesj 7359c21
add upstream
sealesj 0af0bdd
replace Requests library with urllib, remove pylint wrapper
sealesj 0cb1ff8
lint
sealesj c290fb7
undo license
sealesj 90b85dc
clone test nit
sealesj b2295cd
isinstance
sealesj c6c6313
DEPS formatting
sealesj 039e5c5
use subprocess.check_output
sealesj 70a9377
lint
sealesj 157f49e
lint
sealesj 4e304ba
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj ad81446
Merge branch 'flutter:main' into osv-scan
sealesj 099d901
review syntax from comments
sealesj 4309fce
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 02fa6b4
remove line
sealesj b1fa0b9
more description in error
sealesj aa9f4f6
lint
sealesj 00bb405
fix checkout path
sealesj 83af3bd
remove duplicate eval
sealesj 1d674da
lint
sealesj 8b53b4a
lint
sealesj 0c651bf
lint
sealesj c888420
clone-test mkdir and cleanup
sealesj 6362cfd
use shutil.rmtree for non-empty dir
sealesj b347320
lint
sealesj c1ba498
linting
sealesj aa420ac
linting
sealesj d991bf6
var name
sealesj f33c848
Update ci/deps_parser_tests.py
sealesj c49fbd5
Update ci/deps_parser_tests.py
sealesj e5b5b0f
more description
sealesj f49ead5
lint
sealesj cb1b4f2
Merge branch 'osv-scan' of github.com:sealesj/engine into osv-scan
sealesj 8aff9ba
refactor deps file parsing
sealesj 39a404e
early return
sealesj 20804a9
Merge branch 'flutter:main' into osv-scan
sealesj c94df9b
lint
sealesj 6c0ecfe
Merge branch 'osv-scan' of https://github.com/sealesj/engine into osv…
sealesj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
Member
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/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 & | ||
| # upstream names and URLs from DEPs file. | ||
| def setUp(self): # lower-camel-case for the python unittest framework | ||
| # Read the content. | ||
| with open(DEPS, 'r') as file: | ||
| deps_content = file.read() | ||
|
|
||
| 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) | ||
|
|
||
| # Extract the upstream URLs | ||
| # vars contains more than just upstream URLs | ||
| # however the upstream URLs are prefixed with 'upstream_' | ||
| upstream = local_scope_mirror.get('vars') | ||
| self.upstream_urls = upstream | ||
|
|
||
| # 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. ' + | ||
| 'Each dep in the "deps" section of DEPS file must have associated upstream URL' | ||
| ) | ||
|
|
||
| def test_each_upstream_url_has_dep(self): | ||
| # 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. | ||
| for upsream_dep in self.upstream_urls: | ||
| # 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 | ||
| self.assertTrue( | ||
| upsream_dep[len(UPSTREAM_PREFIX):] in deps_names, | ||
| msg=upsream_dep + ' from upstream list not found in DEPS. ' + | ||
| 'Each upstream URL in DEPS file must have an associated dep in the "deps" section' | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.