mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
metrics_xml_format: check the XML path against realpath
metrics_xml_format checks the given file path to ensure that it's an XML under tools/metrics with the following steps. 1. convert the input file path as a real path. 2. check the real path starts with GetPrimarySolutionPath() + "/tools/metrics" This doesn't work as intended if GetPrimarySolutionPath() returns a symblink. This patch converts GetPrimarySolutionPath() as a realpath to ensure it runs the check based on the realpath of the git checkout. Bug: 396182402 Change-Id: I3207eba7ed52d09a01b38d65fcf7c314622d95cb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6279842 Auto-Submit: Scott Lee <ddoman@chromium.org> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import sys
|
||||
|
||||
|
||||
def GetMetricsDir(top_dir, path):
|
||||
top_dir = os.path.realpath(top_dir)
|
||||
metrics_xml_dirs = [
|
||||
os.path.join(top_dir, 'tools', 'metrics', 'actions'),
|
||||
os.path.join(top_dir, 'tools', 'metrics', 'histograms'),
|
||||
@@ -45,10 +46,12 @@ def FindMetricsXMLFormatterTool(path, verbose=False):
|
||||
if not top_dir:
|
||||
log('Not executed in a Chromium checkout; skip formatting', verbose)
|
||||
return ''
|
||||
|
||||
xml_dir = GetMetricsDir(top_dir, path)
|
||||
if not xml_dir:
|
||||
log(f'{path} is not a metric XML; skip formatting', verbose)
|
||||
return ''
|
||||
|
||||
# Just to ensure that the given file is located in the current checkout
|
||||
# folder. If not, skip the formatting.
|
||||
if not os.path.realpath(path).startswith(os.path.realpath(top_dir)):
|
||||
|
||||
Reference in New Issue
Block a user