Commit 15745e25 authored by Nicolas Arciniega's avatar Nicolas Arciniega Committed by Commit Bot

Fix typos in traffic annotation code and docs

This change fills in some missing documentation. I ran a spell
checker throughout traffic auditor code and corrected a bunch of
miscellaneous typos as well :)

Bug: 1005537
Change-Id: I1dab786db686370e2271828089ac336dbc048913
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814721
Commit-Queue: Nicolas Arciniega <niarci@microsoft.com>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704330}
parent aaffcead
...@@ -117,7 +117,7 @@ Each network traffic annotation should specify the following items: ...@@ -117,7 +117,7 @@ Each network traffic annotation should specify the following items:
the source code has hardcoded that the request goes to Google (e.g. for the source code has hardcoded that the request goes to Google (e.g. for
ZeroSuggest), use `GOOGLE_OWNED_SERVICE`. If the request can go to other ZeroSuggest), use `GOOGLE_OWNED_SERVICE`. If the request can go to other
domains and is perceived as a part of a website rather than a native domains and is perceived as a part of a website rather than a native
browser feature, use `WEBSITE`. Use `LOCAL` if the reques is processed browser feature, use `WEBSITE`. Use `LOCAL` if the request is processed
locally and doesn't go to network, otherwise use `OTHER`. If `OTHER` is locally and doesn't go to network, otherwise use `OTHER`. If `OTHER` is
used, please add plain text description in `destination_other` used, please add plain text description in `destination_other`
field. field.
...@@ -302,9 +302,9 @@ clients, and one can run it manually. ...@@ -302,9 +302,9 @@ clients, and one can run it manually.
### Waterfall tests ### Waterfall tests
Two commit queue trybots test traffic annotations on changed files using the Two commit queue trybots test traffic annotations on changed files using the
scripts in `tools/traffic_annotation/scripts`. To run these tests faster and to scripts in `tools/traffic_annotation/scripts`. To run these tests faster and to
avoid spamming the commit queue if an unforeseen error has happed in downstream avoid spamming the commit queue if an unforeseen error has happened in
scripts or tools, they are run in error resilient mode, only on changed files, downstream scripts or tools, they are run in error resilient mode, only on
and using heuristics to decide which files to process. changed files, and using heuristics to decide which files to process.
An FYI bot runs more detailed tests on the whole repository and with different An FYI bot runs more detailed tests on the whole repository and with different
switches, to make sure that the heuristics that trybot tests use and the limited switches, to make sure that the heuristics that trybot tests use and the limited
scope of tests have not neglected any issues. scope of tests have not neglected any issues.
...@@ -434,4 +434,4 @@ values for the mutable annotations. ...@@ -434,4 +434,4 @@ values for the mutable annotations.
For serialization of network traffic annotation and partial network traffic For serialization of network traffic annotation and partial network traffic
annotation tags, you can use the mutable mojo interfaces defined in annotation tags, you can use the mutable mojo interfaces defined in
`/services/network/public/mojom`. `/services/network/public/mojom`.
\ No newline at end of file
...@@ -8,13 +8,13 @@ requires annotation, is annotated, and annotations are sound and complete. ...@@ -8,13 +8,13 @@ requires annotation, is annotated, and annotations are sound and complete.
# Traffic Annotation Auditor # Traffic Annotation Auditor
This is the main executable for all the tests. It runs Traffic Annotation This is the main executable for all the tests. It runs Traffic Annotation
Extractor clang tool to check the repository, extract annotations, and perform Extractor clang tool to check the repository, extract annotations, and perform
required tests and maintanance. See more details in required tests and maintenance. See more details in
`tools/traffic_annotation/auditor/README.md`. `tools/traffic_annotation/auditor/README.md`.
# Traffic Annotation Extractor # Traffic Annotation Extractor
Traffic Annotation Auditor uses this clang tool (located in Traffic Annotation Auditor uses this clang tool (located in
`tools\clang\traffic_annotation_extractor`) to parse the code and extract `tools\clang\traffic_annotation_extractor`) to parse the code and extract
required data for testing and maintanance. required data for testing and maintenance.
# Building the Checkers # Building the Checkers
We do not want every developer to have to build clang tool and auditor, and so We do not want every developer to have to build clang tool and auditor, and so
...@@ -26,7 +26,7 @@ folder. To roll new versions of the binaries, please see ...@@ -26,7 +26,7 @@ folder. To roll new versions of the binaries, please see
# Automatic Annotation Tests # Automatic Annotation Tests
Network traffic annotations are tested in commit queue using Network traffic annotations are tested in commit queue using
`tools/traffic_annotation/scripts/check_annotations.py`. This test is currently `tools/traffic_annotation/scripts/check_annotations.py`. This test is currently
run on Linux and Windows trybots, but may expand in future to other platfroms. run on Linux and Windows trybots, but may expand in future to other platforms.
To perform this test fast enough for a trybot and to avoid spamming the commit To perform this test fast enough for a trybot and to avoid spamming the commit
queue if an unexpected general failure happens (see next item), trybot tests are queue if an unexpected general failure happens (see next item), trybot tests are
run in error resilient mode and only on the changed files. A more complete test run in error resilient mode and only on the changed files. A more complete test
......
# Network Traffic Annotation Auditor # Network Traffic Annotation Auditor
This binary runs the clang tool for extraction of Network Traffic Annotations This binary runs the clang tool for extraction of Network Traffic Annotations
from chromium source code, collects and summarizes its outputs, and performs from chromium source code, collects and summarizes its outputs, and performs
tests and maintanance. tests and maintenance.
Please see `docs/network_traffic_annotations.md` for an introduction to network Please see `docs/network_traffic_annotations.md` for an introduction to network
traffic annotations. traffic annotations.
...@@ -33,7 +33,7 @@ separated, specifying the safe lists based on ...@@ -33,7 +33,7 @@ separated, specifying the safe lists based on
Use * as wildcard for zero or more characters when specifying file paths. Use * as wildcard for zero or more characters when specifying file paths.
Here are the exception types: Here are the exception types:
* `all`: Files and paths in this category are excempted from all tests. * `all`: Files and paths in this category are exempted from all tests.
* `missing`: Files and paths in this category can use the * `missing`: Files and paths in this category can use the
MISSING_TRAFFIC_ANNOTATION tag. MISSING_TRAFFIC_ANNOTATION tag.
* `mutable_tag`: Files and paths in this category can use the * `mutable_tag`: Files and paths in this category can use the
...@@ -41,3 +41,5 @@ Here are the exception types: ...@@ -41,3 +41,5 @@ Here are the exception types:
* `direct_assignment`: The functions in this category can assign a value * `direct_assignment`: The functions in this category can assign a value
directly to a MutableNetworkTrafficAnnotationTag. This is controlled to directly to a MutableNetworkTrafficAnnotationTag. This is controlled to
avoid assigning arbitrary values to mutable annotations. avoid assigning arbitrary values to mutable annotations.
* `test_annotation`: Files and paths in this category can use the
TRAFFIC_ANNOTATION_FOR_TESTS tag.
...@@ -12,7 +12,7 @@ class AuditorResult { ...@@ -12,7 +12,7 @@ class AuditorResult {
public: public:
enum class Type { enum class Type {
RESULT_OK, // No error RESULT_OK, // No error
RESULT_IGNORE, // The item does not require furthure processing. RESULT_IGNORE, // The item does not require further processing.
ERROR_FATAL, // A fatal error that should stop process. ERROR_FATAL, // A fatal error that should stop process.
ERROR_MISSING_TAG_USED, // A function is called with ERROR_MISSING_TAG_USED, // A function is called with
// MISSING_TRAFFIC_ANNOTATION tag. // MISSING_TRAFFIC_ANNOTATION tag.
...@@ -43,7 +43,7 @@ class AuditorResult { ...@@ -43,7 +43,7 @@ class AuditorResult {
// annotation is not paired with any other // annotation is not paired with any other
// annotation to be completed. // annotation to be completed.
ERROR_DIRECT_ASSIGNMENT, // A value is directly assigned to a mutable ERROR_DIRECT_ASSIGNMENT, // A value is directly assigned to a mutable
// annotation or annotation instialized with // annotation or annotation initialized with
// list expresssion. // list expresssion.
ERROR_ANNOTATIONS_XML_UPDATE, // Annotations XML requires update. ERROR_ANNOTATIONS_XML_UPDATE, // Annotations XML requires update.
ERROR_TEST_ANNOTATION, // Annotation for tests is used. ERROR_TEST_ANNOTATION, // Annotation for tests is used.
......
# This is a comma separated file, specifying the safe list for network traffic # This is a comma separated file, specifying the safe list for network traffic
# anntotation auditor. Please refer to README.md for more details. # annotation auditor. Please refer to README.md for more details.
all,tools/*,*test*,*fuzzer*,*mock*,*fake* all,tools/*,*test*,*fuzzer*,*mock*,*fake*
missing,remoting/host/token_validator_factory_impl.cc missing,remoting/host/token_validator_factory_impl.cc
missing,components/cronet/cronet_url_request.cc missing,components/cronet/cronet_url_request.cc
......
...@@ -311,7 +311,7 @@ void TrafficAnnotationAuditor::WriteClangToolOptions( ...@@ -311,7 +311,7 @@ void TrafficAnnotationAuditor::WriteClangToolOptions(
FILE* options_file, FILE* options_file,
bool use_compile_commands) { bool use_compile_commands) {
// As the checked out clang tool may be in a directory different from the // As the checked out clang tool may be in a directory different from the
// default one (third_party/llvm-buid/Release+Asserts/bin), its path and // default one (third_party/llvm-build/Release+Asserts/bin), its path and
// clang's library folder should be passed to the run_tool.py script. // clang's library folder should be passed to the run_tool.py script.
fprintf( fprintf(
options_file, options_file,
...@@ -643,7 +643,7 @@ bool TrafficAnnotationAuditor::CheckIfCallCanBeUnannotated( ...@@ -643,7 +643,7 @@ bool TrafficAnnotationAuditor::CheckIfCallCanBeUnannotated(
// Unittests should be all annotated. Although this can be detected using gn, // Unittests should be all annotated. Although this can be detected using gn,
// doing that would be very slow. The alternative solution would be to bypass // doing that would be very slow. The alternative solution would be to bypass
// every file including test or unittest, but in this case there might be some // every file including test or unittest, but in this case there might be some
// ambiguety in what should be annotated and what not. // ambiguity in what should be annotated and what not.
if (call.file_path.find("unittest") != std::string::npos) if (call.file_path.find("unittest") != std::string::npos)
return false; return false;
......
...@@ -19,7 +19,7 @@ namespace { ...@@ -19,7 +19,7 @@ namespace {
const char* HELP_TEXT = R"( const char* HELP_TEXT = R"(
Traffic Annotation Auditor Traffic Annotation Auditor
Extracts network traffic annotaions from the repository, audits them for errors Extracts network traffic annotations from the repository, audits them for errors
and coverage, produces reports, and updates related files. and coverage, produces reports, and updates related files.
Usage: traffic_annotation_auditor [OPTION]... [path_filters] Usage: traffic_annotation_auditor [OPTION]... [path_filters]
...@@ -67,7 +67,7 @@ Options: ...@@ -67,7 +67,7 @@ Options:
--extractor-backend=[clang_tool,python_script] --extractor-backend=[clang_tool,python_script]
Optional flag specifying which backend to use for Optional flag specifying which backend to use for
extracting annotation definitions from source code (Clang extracting annotation definitions from source code (Clang
Tool or extractor.py). Defaults to "clang_tool". Tool or extractor.py). Defaults to "python_script".
path_filters Optional paths to filter which files the tool is run on. path_filters Optional paths to filter which files the tool is run on.
It can also include deleted files names when auditor is It can also include deleted files names when auditor is
run on a partial repository. run on a partial repository.
......
...@@ -286,7 +286,7 @@ TEST_F(TrafficAnnotationAuditorTest, IsSafeListed) { ...@@ -286,7 +286,7 @@ TEST_F(TrafficAnnotationAuditorTest, IsSafeListed) {
AuditorException::ExceptionType::TEST_ANNOTATION)); AuditorException::ExceptionType::TEST_ANNOTATION));
} }
// Tests if annotation instances are corrrectly deserialized. // Tests if annotation instances are correctly deserialized.
TEST_F(TrafficAnnotationAuditorTest, AnnotationDeserialization) { TEST_F(TrafficAnnotationAuditorTest, AnnotationDeserialization) {
struct AnnotationSample { struct AnnotationSample {
std::string file_name; std::string file_name;
...@@ -340,7 +340,7 @@ TEST_F(TrafficAnnotationAuditorTest, AnnotationDeserialization) { ...@@ -340,7 +340,7 @@ TEST_F(TrafficAnnotationAuditorTest, AnnotationDeserialization) {
} }
} }
// Tests if call instances are corrrectly deserialized. // Tests if call instances are correctly deserialized.
TEST_F(TrafficAnnotationAuditorTest, CallDeserialization) { TEST_F(TrafficAnnotationAuditorTest, CallDeserialization) {
struct CallSample { struct CallSample {
std::string file_name; std::string file_name;
...@@ -369,7 +369,7 @@ TEST_F(TrafficAnnotationAuditorTest, CallDeserialization) { ...@@ -369,7 +369,7 @@ TEST_F(TrafficAnnotationAuditorTest, CallDeserialization) {
} }
} }
// Tests if call instances are corrrectly deserialized. // Tests if call instances are correctly deserialized.
TEST_F(TrafficAnnotationAuditorTest, AssignmentDeserialization) { TEST_F(TrafficAnnotationAuditorTest, AssignmentDeserialization) {
struct Assignmentample { struct Assignmentample {
std::string file_name; std::string file_name;
......
...@@ -74,7 +74,7 @@ void network_traffic_annotation_sample() { ...@@ -74,7 +74,7 @@ void network_traffic_annotation_sample() {
// Example for Nx1 partial annotations where the partial annotations are defined // Example for Nx1 partial annotations where the partial annotations are defined
// in PrefetchImage1 and PrefetchImage2, and the completing annotation is // in PrefetchImage1 and PrefetchImage2, and the completing annotation is
// defined in GetBitmap. Patial annotations are missing cookies fields and are // defined in GetBitmap. Partial annotations are missing cookies fields and are
// completed in GetBitmap function. // completed in GetBitmap function.
void PrefetchImage1(const GURL& url) { void PrefetchImage1(const GURL& url) {
net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation =
...@@ -116,7 +116,7 @@ void PrefetchImage1(const GURL& url) { ...@@ -116,7 +116,7 @@ void PrefetchImage1(const GURL& url) {
void PrefetchImage2(const GURL& url) { void PrefetchImage2(const GURL& url) {
net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation =
net::DefinePartialNetworkTrafficAnnotation("credenential_avatar", net::DefinePartialNetworkTrafficAnnotation("credential_avatar",
"bitmap_fetcher", "bitmap_fetcher",
R"( R"(
semantics { semantics {
......
...@@ -21,4 +21,11 @@ Provides tools for annotation test scripts. ...@@ -21,4 +21,11 @@ Provides tools for annotation test scripts.
# update_annotations_sheet.py # update_annotations_sheet.py
This script updates the Google sheet that presents all network traffic This script updates the Google sheet that presents all network traffic
annotations. annotations.
\ No newline at end of file
# extractor.py
Scans through a set of specified C++ files to detect existing traffic
annotations in code. It uses regex expressions on source files.
# extractor_test.py
Unit tests for extractor.py.
...@@ -55,7 +55,7 @@ class SheetEditor(): ...@@ -55,7 +55,7 @@ class SheetEditor():
silent_change_columns: list of str silent_change_columns: list of str
List of the columns whose changes are not reported in the stats. List of the columns whose changes are not reported in the stats.
last_update_column_name: str last_update_column_name: str
Header of the colunm that keeps the latest update date. Header of the column that keeps the latest update date.
credentials_file_path: str credentials_file_path: str
Absolute path to read/save user credentials. Absolute path to read/save user credentials.
client_secret_file_path: str client_secret_file_path: str
...@@ -378,7 +378,7 @@ def PrintConfigHelp(): ...@@ -378,7 +378,7 @@ def PrintConfigHelp():
"silent_change_columns:\n" "silent_change_columns:\n"
" List of the columns whose changes are not reported in the stats.\n" " List of the columns whose changes are not reported in the stats.\n"
"last_update_column_name:\n" "last_update_column_name:\n"
" Header of the colunm that keeps the latest update date.\n" " Header of the column that keeps the latest update date.\n"
"credentials_file_path:\n" "credentials_file_path:\n"
" Absolute path of the file that keeps user credentials.\n" " Absolute path of the file that keeps user credentials.\n"
"client_secret_file_path:\n" "client_secret_file_path:\n"
...@@ -389,7 +389,7 @@ def PrintConfigHelp(): ...@@ -389,7 +389,7 @@ def PrintConfigHelp():
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Network Traffic Annotations Sheet Updator") description="Network Traffic Annotations Sheet Updater")
parser.add_argument( parser.add_argument(
"--config-file", "--config-file",
help="Configurations file.") help="Configurations file.")
......
...@@ -17,8 +17,8 @@ The following items are stored for each annotation : ...@@ -17,8 +17,8 @@ The following items are stored for each annotation :
* `os_list`: List of all platforms on which this annotation exists. * `os_list`: List of all platforms on which this annotation exists.
Currently only including `linux` and `windows`. Currently only including `linux` and `windows`.
* `file_path`: The file path of the annotation. * `file_path`: The file path of the annotation.
* `reserved`: Reserverd annotations (like annotation for test files) have this * `reserved`: Reserved annotations (like annotation for test files) have this
attribute. If annotation is a reserverd one, it does not have attribute. If annotation is a reserved one, it does not have
`content_hash_code` and `file_path` attributes. `content_hash_code` and `file_path` attributes.
* `deprecated`: Once an annotation is removed from the repository, this * `deprecated`: Once an annotation is removed from the repository, this
attribute is added to its item with value equal to the deprecation date, and attribute is added to its item with value equal to the deprecation date, and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment