• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

tests/23-Nov-2023-365308

CMakeLists.txtD23-Nov-2023481 2925

README.mdD23-Nov-20232.6 KiB6051

traffic_annotation_extractor.cppD23-Nov-202318.2 KiB445311

README.md

1# Traffic Annotation Extrator
2This is a clang tool to extract network traffic annotations. The tool is run by
3`tools/traffic_annotation/auditor/traffic_annotation_auditor`. Refer to it for
4help on how to use.
5
6## Build on Linux
7`tools/clang/scripts/update.py --bootstrap --force-local-build
8   --without-android --extra-tools traffic_annotation_extractor`
9
10## Build on Window
111. Either open a `VS2015 x64 Native Tools Command Prompt`, or open a normal
12   command prompt and run `depot_tools\win_toolchain\vs_files\
13   $long_autocompleted_hash\win_sdk\bin\setenv.cmd /x64`
142. Run `python tools/clang/scripts/update.py --bootstrap --force-local-build
15   --without-android --extra-tools traffic_annotation_extractor`
16
17## Usage
18Run `traffic_annotation_extractor --help` for parameters help.
19
20Example for direct call:
21  `third_party/llvm-build/Release+Asserts/bin/traffic_annotation_extractor
22     -p=out/Debug components/spellcheck/browser/spelling_service_client.cc`
23
24Example for call using run_tool.py:
25  `tools/clang/scripts/run_tool.py --tool=traffic_annotation_extractor
26     --generate-compdb -p=out/Debug components/spellcheck/browser`
27
28The executable extracts network traffic annotations and calls to network request
29  generation functions from given file paths based on build parameters in build
30  path, and writes them to llvm::outs. It also finds all code sites in which a
31  network traffic annotation tag or any of its variants are directly assigned
32  using a list expression constructor or assignment to its |unique_id_hash_code|
33  argument.
34
35Each annotation output will have the following format:
36  - Line 1: "==== NEW ANNOTATION ===="
37  - Line 2: File path.
38  - Line 3: Name of the function in which the annotation is defined.
39  - Line 4: Line number of the annotation.
40  - Line 5: Function type ("Definition", "Partial", "Completing",
41            "BranchedCompleting").
42  - Line 6: Unique id of annotation.
43  - Line 7: Completing id or group id, when applicable, empty otherwise.
44  - Line 8-: Serialized protobuf of the annotation. (Several lines)
45  - Last line:  "==== ANNOTATION ENDS ===="
46
47Each function call output will have the following format:
48  - Line 1: "==== NEW CALL ===="
49  - Line 2: File path.
50  - Line 3: Name of the function in which the call is made.
51  - Line 4: Name of the called function.
52  - Line 5: Does the call have an annotation?
53  - Line 6: "==== CALL ENDS ===="
54
55Each direct assignment output will have the following format:
56  - Line 1: "==== NEW ASSIGNMENT ===="
57  - Line 2: File path.
58  - Line 3: Name of the function in which assignment is done.
59  - Line 4: Line number of the assignment.
60  - Line 5: "==== ASSIGNMENT ENDS ===="