Compare commits

..

180 Commits

Author SHA1 Message Date
Michael B. Gale
2584c99954 Ensure SetFormatterAssignment lhs/rhs match up 2023-02-08 13:05:58 +00:00
Michael B. Gale
24b7d8bb48 Fix isFormatter comment 2023-02-08 13:05:20 +00:00
Michael B. Gale
03079ffd76 Use instanceof 2023-02-08 10:58:52 +00:00
Michael B. Gale
02710a7e11 Check that formatter assignment isn't conditional 2023-02-08 10:52:53 +00:00
Michael B. Gale
7802f57628 Make it clearer that formatters may be santizing 2023-01-18 18:07:58 +00:00
Michael B. Gale
c93e7db831 Rename isSanitizerNode to isFormatter 2023-01-18 18:07:57 +00:00
Michael B. Gale
65beb08d5f Move go generate comments above imports 2023-01-18 18:07:57 +00:00
Michael B. Gale
af6ba6e9c7 Inline LoggerFormatter class 2023-01-18 18:07:57 +00:00
Michael B. Gale
425a4eb7df Make it easier to add new sanitizing formatters
Introduce abstract `SanitizingFormatter` class as a base for all
sanitizing formatters
2023-01-18 18:07:57 +00:00
Michael B. Gale
b2c07a4d4e Use uses instead of refersTo 2023-01-18 18:07:56 +00:00
Michael B. Gale
a7abebf76f Add change note 2023-01-18 18:07:56 +00:00
Michael B. Gale
7671c4a539 Fix style issues 2023-01-18 18:07:56 +00:00
Michael B. Gale
ec41ea8382 Reduce number of alerts for logrus
If a call to `SetFormatter` is present for a sanitizing formatter
such as `JSONFormatter`, then we discard alerts for CWE-117
(`go/log-injection`)
2023-01-18 18:07:55 +00:00
Michael Nebel
3a4623b437 Merge pull request #11907 from michaelnebel/csharp/cil/attributes
C#: CIL attributes
2023-01-18 10:46:34 +01:00
Rasmus Wriedt Larsen
e0ccb9306a Merge pull request #11908 from RasmusWL/dataflow-consistency-more-excludes
DataFlow: Add `uniqueParameterNodePositionExclude`
2023-01-18 10:44:51 +01:00
AlexDenisov
8910ba4f32 Merge pull request #11919 from github/redsun82/swift-obsolete-conf
Swift: remove obsolete configuration fields
2023-01-18 10:34:24 +01:00
Tony Torralba
c8e894b854 Merge pull request #11917 from github/workflow/coverage/update
Update CSV framework coverage reports
2023-01-18 10:02:22 +01:00
Erik Krogh Kristensen
1a64393c4c Merge pull request #11893 from erik-krogh/csharpIndexFiles
C#: add --working-dir=. to pre-finalize
2023-01-18 09:05:29 +01:00
Paolo Tranquilli
2c4c2dfeb3 Swift: remove obsolete configuration fields 2023-01-18 08:55:59 +01:00
Michael Nebel
8e3e6505ad C#: Add change note. 2023-01-18 07:56:24 +01:00
github-actions[bot]
571942fb21 Add changed framework coverage reports 2023-01-18 00:17:19 +00:00
Jeroen Ketema
6cd52237c3 Merge pull request #11913 from jketema/test-fixes
C++: Some minor test fixes
2023-01-17 21:52:57 +01:00
yoff
5a82012d03 Merge pull request #11854 from yoff/python/fix-tarslip-improv-bug
Python: fix bug  in `py/tarslip-extended`
2023-01-17 20:44:06 +01:00
Jeroen Ketema
ee19c3d80f C++: Rename identically named classes in syntax-zoo
Conceptually the test that comprises the whole of `syntax-zoo` forms one
single binary. To this binary ODR applies. There were two class definitions
`Foo` in `syntax-zoo`, violating ODR. Rename those classes to have different
names.
2023-01-17 19:02:40 +01:00
Jeroen Ketema
06767c6760 C++: Split bad_asts.cpp IR test into two files
The statements from `errorExpr` - which does not parse correctly - affected the
tuples that were being generated for the other code in `bad_asts.cpp` due to
the way the front-end handles parse errors. This did not affect the test
results, but was also not the intention of the test. Split off `errorExpr` into
a separate file.
2023-01-17 18:57:29 +01:00
Geoffrey White
ea06ad1933 Merge pull request #11529 from geoffw0/format
Swift: Uncontrolled format string query
2023-01-17 16:16:10 +00:00
Edward Minnix III
4c018759c8 Merge pull request #11283 from egregius313/egregius313/webview-setAllowContentAccess
Java: Android WebView Content Access Query
2023-01-17 11:02:47 -05:00
Michael Nebel
62533501fe C#: Update CIL attributes test case and the expected output. 2023-01-17 17:00:01 +01:00
Geoffrey White
54b3262d9c Merge pull request #11891 from geoffw0/authbypass
C++: Fix issue with cpp/user-controlled-bypass
2023-01-17 15:43:08 +00:00
Jami
babdee36aa Merge pull request #11779 from jcogs33/jcogs33/model-more-top-jdk-apis
Java: model top JDK APIs
2023-01-17 10:20:32 -05:00
Geoffrey White
d628cc5ab8 Update cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-01-17 14:37:19 +00:00
Paolo Tranquilli
6b43ff45a4 Merge pull request #11904 from github/redsun82/swift-extension-protocols
Swift: extract `ExtensionDecl` protocols
2023-01-17 15:16:20 +01:00
Paolo Tranquilli
d9bd41b8b1 Merge pull request #11571 from github/redsun82/swift-open-redirection
Swift: generalize open redirection on both platforms and rework output rewriting
2023-01-17 15:15:56 +01:00
Jami Cogswell
10f0975812 Java: remove models for System.[get|set]Property 2023-01-17 08:51:48 -05:00
Paolo Tranquilli
9e5db7c6ec Merge branch 'main' into redsun82/swift-extension-protocols 2023-01-17 14:39:09 +01:00
Michael Nebel
5f57a097ab C#: CIL method attribute extraction. 2023-01-17 14:17:35 +01:00
Michael Nebel
951f6362aa Merge pull request #11825 from michaelnebel/csharp/genericmathsupport
C# 11: Support for static virtual and static abstract interface members.
2023-01-17 14:14:02 +01:00
Rasmus Wriedt Larsen
a0b1c2ea79 DataFlow: Add uniqueParameterNodePositionExclude 2023-01-17 14:05:22 +01:00
Rasmus Wriedt Larsen
2b0a5fd5d1 DataFlow: Add uniqueParameterNodeAtPositionExclude 2023-01-17 14:05:17 +01:00
Erik Krogh Kristensen
2e4f4c64fe Merge pull request #11903 from erik-krogh/revertClap
QL: Revert "update clap to 3.0 in QL-for-QL"
2023-01-17 13:29:04 +01:00
Paolo Tranquilli
0a792f2f61 Swift: add upgrade and downgrade scripts for ExtensionDecl new protocols property 2023-01-17 13:07:02 +01:00
Paolo Tranquilli
0d32f00020 Swift: update ExtensionDecl test results 2023-01-17 12:58:02 +01:00
Paolo Tranquilli
d6e0ef9ff9 Swift: extract ExtensionDecl protocols 2023-01-17 12:56:09 +01:00
Paolo Tranquilli
f6e26211f9 Swift: add protocols to ExtensionDecl schema 2023-01-17 12:54:50 +01:00
Paolo Tranquilli
8906e101cb Swift: add ExtensionDecl QL test 2023-01-17 12:49:53 +01:00
erik-krogh
5a4fe71529 Revert "update clap to 3.0 in QL-for-QL"
This reverts commit d072ed969e.
2023-01-17 12:38:30 +01:00
Erik Krogh Kristensen
50b9f5bba0 Merge pull request #11892 from erik-krogh/clap
QL: update clap to 3.0 in QL-for-QL
2023-01-17 12:33:18 +01:00
Mathias Vorreiter Pedersen
77a9cea737 Merge pull request #11901 from github/redsun82/swift-ql-internal
Swift: introduce `@ql.internal` pragma for classes
2023-01-17 10:46:56 +00:00
Paolo Tranquilli
67bd8cba32 Merge pull request #11900 from github/alexdenisov/swift-ignore-lsregister
Swift: do not trace lsregister
2023-01-17 11:26:22 +01:00
Chris Smowton
29425982a5 Merge pull request #11899 from ataillefer/patch-1
Fix partial path traversal Java example
2023-01-17 09:39:36 +00:00
Paolo Tranquilli
6106edd5e2 Swift: add INTERNAL doc marker to ql.internal classes 2023-01-17 10:30:59 +01:00
Paolo Tranquilli
b22da25e05 Swift: remove ql.internal classes from global import 2023-01-17 10:18:03 +01:00
Paolo Tranquilli
48825442c3 Swift: add ql.internal pragma in schema definitions 2023-01-17 10:10:35 +01:00
Paolo Tranquilli
cdc99b5240 Swift: simplify pragma definition 2023-01-17 10:10:02 +01:00
Paolo Tranquilli
e3502e2e5f Merge branch 'main' into redsun82/swift-open-redirection 2023-01-17 09:43:00 +01:00
Alex Denisov
63b4e5ef5c Swift: do not trace lsregister 2023-01-17 09:26:31 +01:00
Antoine Taillefer
660e6d7085 Fix partial path traversal Java example
The Java recommendation example for the "Partial path traversal vulnerability from remote" query doesn't seem right to me. Indeed, the following statement doesn't compile, since `dir.getCanonicalPath()` returns a String:
```
dir.getCanonicalPath().toPath()
```
Maybe the author wanted to state `dir.getCanonicalFile().toPath()`, which would compile, but is useless compared to `dir.getCanonicalPath()`.

Moreover, `parent.getCanonicalFile().toPath()` or `parent.getCanonicalPath()` will **not** be slash-terminated, contrary to what the description says.
From what I can see (and test), the correct fix is to concatenate `File.separator` to the parent canonical path.
2023-01-16 21:14:29 +01:00
erik-krogh
dcc1c3d487 add --working-dir=. to pre-finalize for c# 2023-01-16 18:09:00 +01:00
Michael Nebel
8981d4c06b C#: Add change note. 2023-01-16 13:43:26 +01:00
Michael Nebel
2f602a629f C#: Add upgrade and downgrade scripts. 2023-01-16 13:27:37 +01:00
Michael Nebel
3552a41552 C#: Add test case for static abstract and static virtual interface members. 2023-01-16 13:07:50 +01:00
Michael Nebel
dc50b6bad3 C#: Support for operators in implements relations. 2023-01-16 13:07:50 +01:00
Michael Nebel
8c2931cbb8 C#: Operators are now allowed to be declared virtual. 2023-01-16 13:07:50 +01:00
erik-krogh
d072ed969e update clap to 3.0 in QL-for-QL 2023-01-16 12:34:56 +01:00
Paolo Tranquilli
874fe2b8f9 Swift: introduce an in-memory file hash cache
File hashing is now done internally in `SwiftFileInterception` (and
exported as a `getHashOfRealFile` function for future use in linkage
awareness), and using a per-process in-memory cache. The persistent
caching of paths is removed, so the solution is now robust against input
file changes during the build.

For the same reason, the hash to artifact mapping have the symlinks
reversed now. The artifacts themselves are stored using the hash as
filenames, and the original paths of the artifacts are reacreated in the
scratch dir with symlinks mostly for debugging purposes (to understand
what artifact each hash corresponds to, and to follow what was built by
the extractor).
2023-01-16 12:05:36 +01:00
Paolo Tranquilli
738412260f Merge branch 'main' into redsun82/swift-open-redirection 2023-01-16 09:09:10 +01:00
Geoffrey White
1a416884d4 C++: Do something similar with the other three cases. 2023-01-14 00:09:01 +00:00
Geoffrey White
316117f5c9 C++: Reduce number of regexps. 2023-01-13 18:50:41 +00:00
Geoffrey White
2f09f0e2c1 C++: Turn the huge list into a predicate. 2023-01-13 18:47:18 +00:00
Geoffrey White
13ae15b867 C++: Add tests for more edge cases. 2023-01-13 18:38:29 +00:00
Jami Cogswell
fb6725ddaa Java: add WithoutElement comment for clear methods 2023-01-13 13:20:45 -05:00
Jami Cogswell
a43f3cf95f Java: remove Supplier.get model 2023-01-12 17:09:13 -05:00
Jami Cogswell
f040ff2d8d Java: undo change to Function.apply test case 2023-01-12 17:01:58 -05:00
Jami Cogswell
c3a1d088ac Java: update change note 2023-01-12 16:32:52 -05:00
Jami Cogswell
a39b2aaaac Java: remove endsWith test case 2023-01-12 16:24:57 -05:00
Jami Cogswell
ffb267937a Java: add endsWith additionalTaintStep to ConditionalBypassFlowConfig 2023-01-12 16:24:05 -05:00
Jami Cogswell
e0444449c8 Java: remove Function.apply model 2023-01-12 09:58:53 -05:00
Paolo Tranquilli
4f5f0aad45 Merge branch 'main' into redsun82/swift-open-redirection 2023-01-12 10:54:04 +01:00
Jami Cogswell
fd593fd4f0 Java: undo changes to tests that were affected by numeric-flow summary models 2023-01-11 22:34:19 -05:00
Jami Cogswell
ce74c9d959 Java: Date models as neutral 2023-01-11 22:15:41 -05:00
Jami Cogswell
6bb865ad05 Java: make numeric flow models neutral 2023-01-11 18:04:43 -05:00
Jami Cogswell
0c7ffb0554 Java: update System.getProperty model 2023-01-11 12:04:22 -05:00
Jami Cogswell
2a99af0e6d Java: remove summary model for String.endsWith 2023-01-11 10:58:46 -05:00
Jami Cogswell
99ee6c95a1 Java: remove models for Consumer.accept and Collectors.toMap 2023-01-11 10:44:38 -05:00
Jami Cogswell
ac064ac2a7 Java: remove model for Collectors.joining 2023-01-11 10:30:49 -05:00
Jami Cogswell
181a711f04 Java: switch Collectors.joining model from neutral to summary 2023-01-10 21:06:03 -05:00
Rasmus Lerchedahl Petersen
2edbfbf8bc python: update test expectations
...now the bug is fixed
2023-01-09 20:35:20 +01:00
Rasmus Lerchedahl Petersen
c142495a8b python: simplify code 2023-01-09 17:51:45 +01:00
Rasmus Lerchedahl Petersen
5fe62e293a python: fix bug, add clarifying comment 2023-01-09 17:45:50 +01:00
Ed Minnix
909b1d70d9 Rename files to say "Allow" instead of "Permit" 2023-01-09 10:11:03 -05:00
Ed Minnix
c723df3ca7 Fix alert message in expected file 2023-01-09 10:08:19 -05:00
Ed Minnix
f626d4794a Change wording from "permit" to "allow" in id and name 2023-01-09 10:03:12 -05:00
Ed Minnix
972b4629c8 Fix typo in change note 2023-01-09 10:01:38 -05:00
Ed Minnix
64668883a4 Add good example to documentation 2023-01-09 09:59:38 -05:00
Ed Minnix
2ec73c50f9 Mention WebView in alert message 2023-01-09 09:55:09 -05:00
Geoffrey White
9333e80def Swift: Add getVaList stub to the test. 2023-01-09 10:29:37 +00:00
Paolo Tranquilli
82d9edfabf Merge branch 'main' into redsun82/swift-open-redirection 2023-01-09 08:44:02 +01:00
Jami Cogswell
a3c7b2c3a2 Java: move java.lang.Math.min to the correct file 2023-01-06 14:35:09 -05:00
Geoffrey White
e45750a8ca Merge branch 'main' into format 2023-01-04 18:00:59 +00:00
Jami Cogswell
abe501c1af Java: add change note 2023-01-03 17:15:50 -05:00
Jami Cogswell
5d92792e40 Java: update test case affected by Function.apply model 2023-01-03 16:14:08 -05:00
Jami Cogswell
feaae16f7c Java: adjust comments 2023-01-03 16:08:14 -05:00
Edward Minnix III
69fd5e93bc Merge pull request #28 from egregius313/egregisu313/webview-setAllowContentAccess-single-query
Merge `setAllowContentAccess` queries into singular query
2023-01-03 15:27:09 -05:00
Ed Minnix
81df89f93e Use proper @id in changenote 2023-01-03 15:19:26 -05:00
Ed Minnix
28ad9d00fb Merge both setAllowContentAccess queries into one query
Previously, the query to detect whether or not access to `content://`
links was done using two queries.

Now they can be merged into one query
2023-01-03 15:17:07 -05:00
Jami Cogswell
29221ae426 Java: add summary model for System.getProperty, adjust comments 2023-01-03 15:11:21 -05:00
Jami Cogswell
21a018e5c5 Java: add summary model and test for File.getName 2023-01-03 13:12:24 -05:00
Geoffrey White
fc646a6d48 Swift: Update .expected following a toString change in main. 2023-01-03 16:25:14 +00:00
Geoffrey White
e05bb7fcee Merge branch 'main' into format 2023-01-03 15:14:55 +00:00
Ed Minnix
35de551f6b Formatting 2022-12-31 17:19:49 -05:00
Ed Minnix
515fa21aad Change notes 2022-12-31 17:18:37 -05:00
Ed Minnix
df1a4d2ed1 Documentation fix: Add state1 and state2 to documentation 2022-12-31 15:25:37 -05:00
Ed Minnix
68392aa8d8 Fix test expectations 2022-12-31 15:25:25 -05:00
Ed Minnix
02f70f3536 Add @security-severity tag 2022-12-31 15:00:28 -05:00
Edward Minnix III
1d345c6101 Refactoring and simplification
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2022-12-31 15:00:28 -05:00
Ed Minnix
9ef319f659 Java: setAllowContentAccess query tests 2022-12-31 15:00:28 -05:00
Ed Minnix
5265cb4b03 Merge two dataflow configurations into one taint tracking 2022-12-31 15:00:28 -05:00
Ed Minnix
973f649e76 Break dataflow into two steps in order to capture flow from WebView to settings call 2022-12-31 15:00:28 -05:00
Ed Minnix
0e15dd9fa9 Query metadata 2022-12-31 15:00:28 -05:00
Edward Minnix III
778749184b Change id to use android/ instead of prepending android-
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2022-12-31 15:00:28 -05:00
Ed Minnix
da25c586e6 Dataflow query for detecting paths that disable content access
Since the default value is `true`, we need to determine whether or not
the `setAllowContentAccess` method is ever called using dataflow.
2022-12-31 15:00:28 -05:00
Ed Minnix
8a763015e6 Reduce precision rating to medium
This query won't always be a security problem, so it should have a lower
precision rating than `high`.
2022-12-31 15:00:28 -05:00
Ed Minnix
7cc53126f3 Java: WebView setAllowContentAccess query test cases 2022-12-31 15:00:28 -05:00
Ed Minnix
a023726c03 Java: add Android stubs to options file for CWE-200 tests 2022-12-31 15:00:28 -05:00
Ed Minnix
e4e13d38b7 Java: query for Android WebView setAllowContentAccess 2022-12-31 15:00:28 -05:00
Ed Minnix
e259ef5d1d Java: Add class for android.webkit.WebSettings.setAllowContentAccess 2022-12-31 15:00:28 -05:00
Jami Cogswell
939279af38 Java: add comments 2022-12-22 16:25:12 -05:00
Jami Cogswell
673d37cc3d Java: update Math.min test case 2022-12-22 14:36:06 -05:00
Jami Cogswell
a81c54b58c Java: updates to order alphabetically 2022-12-22 13:22:12 -05:00
Jami Cogswell
e6331dc2e6 Java: update test case affected by Long.parseLong summary model 2022-12-22 12:57:37 -05:00
Jami Cogswell
997219a280 Java: update test case affected by Class.isAssignableFrom neutral model 2022-12-22 12:54:02 -05:00
Jami Cogswell
6007827dd3 Java: update test cases 2022-12-22 12:29:57 -05:00
Jami Cogswell
de5965525f Java: add initial test cases for summary models 2022-12-21 16:19:37 -05:00
Jami Cogswell
c251da799f Java: update TopJdkApis test 2022-12-21 13:19:09 -05:00
Jami Cogswell
16de30e07e Java: add java.util.stream models 2022-12-21 13:05:23 -05:00
Jami Cogswell
1db829e55c Java: add java.util models 2022-12-21 13:03:57 -05:00
Jami Cogswell
573de92441 Java: add java.util.function models 2022-12-21 12:59:58 -05:00
Jami Cogswell
a8c55ee4b7 Java: add java.util.concurrent models 2022-12-21 12:59:00 -05:00
Jami Cogswell
db0d24fdd1 Java: add java.util.concurrent.atomic models 2022-12-21 12:57:22 -05:00
Jami Cogswell
cfe075ef54 Java: add java.time models 2022-12-21 12:54:35 -05:00
Jami Cogswell
8e20aeb314 Java: add java.text models 2022-12-21 12:51:44 -05:00
Jami Cogswell
b9ce588076 Java: add java.sql models 2022-12-21 12:49:29 -05:00
Jami Cogswell
1544f49f91 Java: add java.math models 2022-12-21 12:47:32 -05:00
Jami Cogswell
ed534b06d5 Java: add java.lang models 2022-12-21 12:45:12 -05:00
Jami Cogswell
99ddd484be Java: add java.io models 2022-12-21 12:34:26 -05:00
Paolo Tranquilli
454af0d721 Swift: fix locking of output swiftmodule trap 2022-12-20 15:34:18 +01:00
Paolo Tranquilli
a1161c6efe Swift: remove header patch which is not needed any more 2022-12-20 15:28:52 +01:00
Paolo Tranquilli
725861626c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-20 15:28:30 +01:00
Geoffrey White
640f894b00 Merge branch 'main' into format 2022-12-16 11:42:03 +00:00
Geoffrey White
1f7d96a74a Merge branch 'main' into format 2022-12-15 15:17:54 +00:00
Paolo Tranquilli
7f505d8715 Swift: do not filter frontend actions 2022-12-15 14:39:43 +01:00
Paolo Tranquilli
208388e04d Swift: hard code libc.dylib path on macOS
Also, handle the corner case where loading libc fails.
2022-12-15 13:30:23 +01:00
Paolo Tranquilli
3084eda28a Swift: add swiftmodule hash map testing to frontend_invocations 2022-12-15 10:33:47 +01:00
Paolo Tranquilli
e42ae09e1c Swift: fix interaction between bash wrapper and open redirection on macOS 2022-12-15 09:50:31 +01:00
Paolo Tranquilli
793de3196b Revert "Swift: accept test changes"
This reverts commit 26ae8f177b.
2022-12-14 18:34:12 +01:00
Paolo Tranquilli
14fd89d482 Swift: generalize output redirection code 2022-12-14 18:26:48 +01:00
Paolo Tranquilli
45c0c7fe6c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-14 18:26:16 +01:00
Paolo Tranquilli
250ac686a2 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-12 08:46:23 +01:00
Paolo Tranquilli
a93e361aca Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 12:19:38 +01:00
Paolo Tranquilli
7162692656 Swift: exit directly on actions not requiring extraction 2022-12-09 10:00:01 +01:00
Paolo Tranquilli
4a41bb4061 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 09:59:21 +01:00
Paolo Tranquilli
26ae8f177b Swift: accept test changes
Downgrading the emit object action to a type check one has some
unexpected side effects, that seem however acceptable:
* experimental false static assertions do not make compilation fail in
  type check mode
* the implicit module loading of `SwiftOnoneSupport` is not happening.
  That module contains some "pre-specializations", it does not seem
  really relevant for analysis
2022-12-08 17:13:00 +01:00
Paolo Tranquilli
d35c5e90ee Swift: remove fishhook 2022-12-08 16:10:44 +01:00
Paolo Tranquilli
bf1b32f210 Swift: rework file redirection
The hash map mechanism that was already in use for reading swiftmodule
files on macOS is now in use also on Linux. The output replacing
mechanism has been also reworked so that:
* frontend module emission modes have the remapping done directly in
  the internal frontend options instead of painstakingly modifying input
  flags (this requires a patch on the swift headers though)
* object emission mode is silenced to be just a type checking pass,
  thus producing no output files
* all other passes but some debugging and version related ones become
  noops

The open file read redirection uses a global weak pointer instance to
maximize robustness in the face of possibly multi-threaded calls to open
happening while `main` is exiting. Possibly overkill, but better safe
than sorry.
2022-12-08 16:10:44 +01:00
Paolo Tranquilli
944adfe727 Swift: allow modifying frontend outputs 2022-12-08 16:10:25 +01:00
Paolo Tranquilli
219ed64b74 Swift: reorganize bazel third party dependencies 2022-12-08 16:10:25 +01:00
Geoffrey White
24ce1c27bc Swift: Autoformat. 2022-12-08 13:09:37 +00:00
Geoffrey White
07ea006cee Swift: Add support for CSV modelled sinks as well. 2022-12-08 11:36:55 +00:00
Geoffrey White
dba344451f Swift: Add UncontrolledFormatStringExtensions.qll. 2022-12-08 11:32:50 +00:00
Geoffrey White
cf3345ee8f Swift: Revert security-severity on CWE-321, for now. 2022-12-02 12:01:43 +00:00
Geoffrey White
85a0a42da9 Swift: try again to satisfy ql-for-ql. 2022-12-02 10:15:11 +00:00
Geoffrey White
f7ebd1312e Swift: Corrections. 2022-12-01 20:13:56 +00:00
Geoffrey White
157a7829ca Swift: correct the example. 2022-12-01 18:35:10 +00:00
Geoffrey White
ad05cc3cb1 Swift: Separate out a FormatString library as well. 2022-12-01 18:09:46 +00:00
Geoffrey White
43596869e7 Swift: Move query logic to a .qll. 2022-12-01 18:09:45 +00:00
Geoffrey White
87fa159384 Swift: Add security-severity, and correct one for another query that apparently wasn't right. 2022-12-01 18:09:39 +00:00
Geoffrey White
58e9a0436e Swift: Add metadata. 2022-12-01 18:09:33 +00:00
Geoffrey White
2b61f26a64 Swift: Add doc. 2022-12-01 16:32:34 +00:00
Geoffrey White
32c4728f83 Swift: Add tests. 2022-12-01 16:32:33 +00:00
Geoffrey White
a2210959b5 Swift: Uncontrolled format string query (initial version). 2022-12-01 16:32:33 +00:00
225 changed files with 33564 additions and 6647 deletions

View File

@@ -45,6 +45,16 @@ module Consistency {
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
}
private class RelevantNode extends Node {
@@ -246,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
@@ -254,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."

View File

@@ -45,6 +45,16 @@ module Consistency {
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
}
private class RelevantNode extends Node {
@@ -246,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
@@ -254,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."

View File

@@ -45,6 +45,16 @@ module Consistency {
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
}
private class RelevantNode extends Node {
@@ -246,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
@@ -254,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."

View File

@@ -15,76 +15,24 @@
import semmle.code.cpp.ir.dataflow.internal.DefaultTaintTrackingImpl
import TaintedWithPath
string getATopLevelDomain() {
result =
[
"com", "ru", "net", "org", "de", "jp", "uk", "br", "pl", "in", "it", "fr", "au", "info", "nl",
"cn", "ir", "es", "cz", "biz", "ca", "eu", "ua", "kr", "za", "co", "gr", "ro", "se", "tw",
"vn", "mx", "ch", "tr", "at", "be", "hu", "tv", "dk", "me", "ar", "us", "no", "sk", "fi",
"id", "cl", "nz", "by", "xyz", "pt", "ie", "il", "kz", "my", "hk", "lt", "cc", "sg", "io",
"edu", "gov"
]
}
predicate hardCodedAddressOrIP(StringLiteral txt) {
exists(string s | s = txt.getValueText() |
// Hard-coded ip addresses, such as 127.0.0.1
s.regexpMatch("\"[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+\"") or
// Hard-coded addresses such as www.mycompany.com
s.matches("\"www.%\"") or
s.matches("\"http:%\"") or
s.matches("\"https:%\"") or
s.matches("\"%.com\"") or
s.matches("\"%.ru\"") or
s.matches("\"%.net\"") or
s.matches("\"%.org\"") or
s.matches("\"%.de\"") or
s.matches("\"%.jp\"") or
s.matches("\"%.uk\"") or
s.matches("\"%.br\"") or
s.matches("\"%.pl\"") or
s.matches("\"%.in\"") or
s.matches("\"%.it\"") or
s.matches("\"%.fr\"") or
s.matches("\"%.au\"") or
s.matches("\"%.info\"") or
s.matches("\"%.nl\"") or
s.matches("\"%.cn\"") or
s.matches("\"%.ir\"") or
s.matches("\"%.es\"") or
s.matches("\"%.cz\"") or
s.matches("\"%.biz\"") or
s.matches("\"%.ca\"") or
s.matches("\"%.eu\"") or
s.matches("\"%.ua\"") or
s.matches("\"%.kr\"") or
s.matches("\"%.za\"") or
s.matches("\"%.co\"") or
s.matches("\"%.gr\"") or
s.matches("\"%.ro\"") or
s.matches("\"%.se\"") or
s.matches("\"%.tw\"") or
s.matches("\"%.vn\"") or
s.matches("\"%.mx\"") or
s.matches("\"%.ch\"") or
s.matches("\"%.tr\"") or
s.matches("\"%.at\"") or
s.matches("\"%.be\"") or
s.matches("\"%.hu\"") or
s.matches("\"%.tv\"") or
s.matches("\"%.dk\"") or
s.matches("\"%.me\"") or
s.matches("\"%.ar\"") or
s.matches("\"%.us\"") or
s.matches("\"%.no\"") or
s.matches("\"%.sk\"") or
s.matches("\"%.fi\"") or
s.matches("\"%.id\"") or
s.matches("\"%.cl\"") or
s.matches("\"%.nz\"") or
s.matches("\"%.by\"") or
s.matches("\"%.xyz\"") or
s.matches("\"%.pt\"") or
s.matches("\"%.ie\"") or
s.matches("\"%.il\"") or
s.matches("\"%.kz\"") or
s.matches("\"%.my\"") or
s.matches("\"%.hk\"") or
s.matches("\"%.lt\"") or
s.matches("\"%.cc\"") or
s.matches("\"%.sg\"") or
s.matches("\"%.io\"") or
s.matches("\"%.edu\"") or
s.matches("\"%.gov\"")
s.regexpMatch("\"(www\\.|http:|https:).*\"") or
s.regexpMatch("\".*\\.(" + strictconcat(getATopLevelDomain(), "|") + ")\"")
)
}

View File

@@ -207,34 +207,35 @@ bad_asts.cpp:
# 27| Type = [SpecifiedType] const Point
# 27| ValueCategory = lvalue
# 28| getStmt(1): [ReturnStmt] return ...
# 30| [TopLevelFunction] void Bad::errorExpr()
# 30| <params>:
# 30| getEntryPoint(): [BlockStmt] { ... }
# 31| getStmt(0): [DeclStmt] declaration
# 31| getDeclarationEntry(0): [VariableDeclarationEntry] definition of intref
# 31| Type = [LValueReferenceType] int &
# 31| getVariable().getInitializer(): [Initializer] initializer for intref
# 31| getExpr(): [ErrorExpr] <error expr>
# 31| Type = [ErroneousType] error
# 31| ValueCategory = prvalue
# 32| getStmt(1): [DeclStmt] declaration
# 32| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
# 32| Type = [IntType] int
# 32| getVariable().getInitializer(): [Initializer] initializer for x
# 32| getExpr(): [ErrorExpr] <error expr>
# 32| Type = [ErroneousType] error
# 32| ValueCategory = prvalue
# 33| getStmt(2): [ExprStmt] ExprStmt
# 33| getExpr(): [AssignExpr] ... = ...
# 33| Type = [IntType] int
# 33| ValueCategory = lvalue
# 33| getLValue(): [VariableAccess] x
# 33| Type = [IntType] int
# 33| ValueCategory = lvalue
# 33| getRValue(): [ErrorExpr] <error expr>
# 33| Type = [ErroneousType] error
# 33| ValueCategory = prvalue(load)
# 34| getStmt(3): [ReturnStmt] return ...
bad_stmts.cpp:
# 5| [TopLevelFunction] void Bad::errorExpr()
# 5| <params>:
# 5| getEntryPoint(): [BlockStmt] { ... }
# 6| getStmt(0): [DeclStmt] declaration
# 6| getDeclarationEntry(0): [VariableDeclarationEntry] definition of intref
# 6| Type = [LValueReferenceType] int &
# 6| getVariable().getInitializer(): [Initializer] initializer for intref
# 6| getExpr(): [ErrorExpr] <error expr>
# 6| Type = [ErroneousType] error
# 6| ValueCategory = prvalue
# 7| getStmt(1): [DeclStmt] declaration
# 7| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
# 7| Type = [IntType] int
# 7| getVariable().getInitializer(): [Initializer] initializer for x
# 7| getExpr(): [ErrorExpr] <error expr>
# 7| Type = [ErroneousType] error
# 7| ValueCategory = prvalue
# 8| getStmt(2): [ExprStmt] ExprStmt
# 8| getExpr(): [AssignExpr] ... = ...
# 8| Type = [IntType] int
# 8| ValueCategory = lvalue
# 8| getLValue(): [VariableAccess] x
# 8| Type = [IntType] int
# 8| ValueCategory = lvalue
# 8| getRValue(): [ErrorExpr] <error expr>
# 8| Type = [ErroneousType] error
# 8| ValueCategory = prvalue(load)
# 9| getStmt(3): [ReturnStmt] return ...
clang.cpp:
# 5| [TopLevelFunction] int* globalIntAddress()
# 5| <params>:

View File

@@ -1,4 +1,4 @@
// semmle-extractor-options: -std=c++17 --expect_errors
// semmle-extractor-options: -std=c++17
// Test cases that illustrate known bad ASTs that we have to work around in IR generation.
namespace Bad {
@@ -26,10 +26,4 @@ namespace Bad {
void CallCopyConstructor(const Point& a) {
Point b = a; // Copy constructor contains literal expressions with no values.
}
void errorExpr() {
int &intref = 0;
int x = 0[0];
x = 1[1];
}
}

View File

@@ -0,0 +1,10 @@
// semmle-extractor-options: -std=c++17 --expect_errors
// Test cases that illustrate known bad ASTs that we have to work around in IR generation.
namespace Bad {
void errorExpr() {
int &intref = 0;
int x = 0[0];
x = 1[1];
}
}

View File

@@ -98,17 +98,17 @@
| bad_asts.cpp:27:15:27:15 | StoreValue | r27_6 |
| bad_asts.cpp:27:15:27:15 | Unary | r27_3 |
| bad_asts.cpp:27:15:27:15 | Unary | r27_4 |
| bad_asts.cpp:30:8:30:16 | ChiPartial | partial:m30_3 |
| bad_asts.cpp:30:8:30:16 | ChiTotal | total:m30_2 |
| bad_asts.cpp:30:8:30:16 | SideEffect | m30_3 |
| bad_asts.cpp:31:10:31:15 | Address | &:r31_1 |
| bad_asts.cpp:31:18:31:19 | StoreValue | r31_2 |
| bad_asts.cpp:32:9:32:9 | Address | &:r32_1 |
| bad_asts.cpp:32:12:32:16 | StoreValue | r32_2 |
| bad_asts.cpp:33:5:33:5 | Address | &:r33_3 |
| bad_asts.cpp:33:5:33:12 | Address | &:r33_1 |
| bad_asts.cpp:33:5:33:12 | Load | ~m30_4 |
| bad_asts.cpp:33:5:33:12 | StoreValue | r33_2 |
| bad_stmts.cpp:5:8:5:16 | ChiPartial | partial:m5_3 |
| bad_stmts.cpp:5:8:5:16 | ChiTotal | total:m5_2 |
| bad_stmts.cpp:5:8:5:16 | SideEffect | m5_3 |
| bad_stmts.cpp:6:10:6:15 | Address | &:r6_1 |
| bad_stmts.cpp:6:18:6:19 | StoreValue | r6_2 |
| bad_stmts.cpp:7:9:7:9 | Address | &:r7_1 |
| bad_stmts.cpp:7:12:7:16 | StoreValue | r7_2 |
| bad_stmts.cpp:8:5:8:5 | Address | &:r8_3 |
| bad_stmts.cpp:8:5:8:12 | Address | &:r8_1 |
| bad_stmts.cpp:8:5:8:12 | Load | ~m5_4 |
| bad_stmts.cpp:8:5:8:12 | StoreValue | r8_2 |
| clang.cpp:5:6:5:21 | Address | &:r5_5 |
| clang.cpp:5:6:5:21 | ChiPartial | partial:m5_3 |
| clang.cpp:5:6:5:21 | ChiTotal | total:m5_2 |

View File

@@ -120,25 +120,26 @@ bad_asts.cpp:
# 26| v26_10(void) = AliasedUse : ~m?
# 26| v26_11(void) = ExitFunction :
# 30| void Bad::errorExpr()
# 30| Block 0
# 30| v30_1(void) = EnterFunction :
# 30| mu30_2(unknown) = AliasedDefinition :
# 30| mu30_3(unknown) = InitializeNonLocal :
# 31| r31_1(glval<int &>) = VariableAddress[intref] :
# 31| r31_2(error) = Error :
# 31| mu31_3(int &) = Store[intref] : &:r31_1, r31_2
# 32| r32_1(glval<int>) = VariableAddress[x] :
# 32| r32_2(error) = Error :
# 32| mu32_3(int) = Store[x] : &:r32_1, r32_2
# 33| r33_1(glval<error>) = Error :
# 33| r33_2(error) = Load[?] : &:r33_1, ~m?
# 33| r33_3(glval<int>) = VariableAddress[x] :
# 33| mu33_4(int) = Store[x] : &:r33_3, r33_2
# 34| v34_1(void) = NoOp :
# 30| v30_4(void) = ReturnVoid :
# 30| v30_5(void) = AliasedUse : ~m?
# 30| v30_6(void) = ExitFunction :
bad_stmts.cpp:
# 5| void Bad::errorExpr()
# 5| Block 0
# 5| v5_1(void) = EnterFunction :
# 5| mu5_2(unknown) = AliasedDefinition :
# 5| mu5_3(unknown) = InitializeNonLocal :
# 6| r6_1(glval<int &>) = VariableAddress[intref] :
# 6| r6_2(error) = Error :
# 6| mu6_3(int &) = Store[intref] : &:r6_1, r6_2
# 7| r7_1(glval<int>) = VariableAddress[x] :
# 7| r7_2(error) = Error :
# 7| mu7_3(int) = Store[x] : &:r7_1, r7_2
# 8| r8_1(glval<error>) = Error :
# 8| r8_2(error) = Load[?] : &:r8_1, ~m?
# 8| r8_3(glval<int>) = VariableAddress[x] :
# 8| mu8_4(int) = Store[x] : &:r8_3, r8_2
# 9| v9_1(void) = NoOp :
# 5| v5_4(void) = ReturnVoid :
# 5| v5_5(void) = AliasedUse : ~m?
# 5| v5_6(void) = ExitFunction :
clang.cpp:
# 5| int* globalIntAddress()

View File

@@ -1,7 +1,7 @@
struct Foo
struct Allocators
{
Foo(int x, int y) : m_x(x), m_y(y) {}
~Foo() {m_x = m_y = 0;}
Allocators(int x, int y) : m_x(x), m_y(y) {}
~Allocators() {m_x = m_y = 0;}
// NB: In Microsoft mode, size_t is predeclared.
static void* operator new(size_t sz, int z, int w) { return nullptr; }
@@ -13,7 +13,7 @@ struct Foo
int main()
{
auto foo = new(11, 22) Foo(33, 44);
auto foo = new(11, 22) Allocators(33, 44);
delete foo;
}

View File

@@ -1,7 +1,7 @@
struct Foo {
~Foo();
struct ArrayDelete {
~ArrayDelete();
};
void f() {
delete[] (Foo*)nullptr;
delete[] (ArrayDelete*)nullptr;
}

View File

@@ -74,8 +74,8 @@ argHasPostUpdate
| ir.cpp:625:5:625:5 | s | ArgumentNode is missing PostUpdateNode. |
postWithInFlow
| VacuousDestructorCall.cpp:10:22:10:22 | i [inner post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:11:4:13 | m_x [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:17:4:19 | m_y [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:18:4:20 | m_x [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:24:4:26 | m_y [post update] | PostUpdateNode should not be the target of local flow. |
| assignexpr.cpp:9:4:9:4 | i [post update] | PostUpdateNode should not be the target of local flow. |
| builtin.c:34:23:34:31 | staticint [inner post update] | PostUpdateNode should not be the target of local flow. |
| builtin.c:39:37:39:45 | carry_out [inner post update] | PostUpdateNode should not be the target of local flow. |

View File

@@ -1483,17 +1483,17 @@ postWithInFlow
| aggregateinitializer.c:3:6:3:6 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| aggregateinitializer.c:3:11:3:27 | PointerAdd [post update] | PostUpdateNode should not be the target of local flow. |
| aggregateinitializer.c:3:11:3:27 | PointerAdd [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:3:23:3:28 | FieldAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:3:31:3:36 | FieldAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:11:4:13 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:11:4:13 | m_x [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:17:4:19 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:17:4:19 | m_y [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:3:30:3:35 | FieldAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:3:38:3:43 | FieldAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:18:4:20 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:18:4:20 | m_x [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:24:4:26 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:4:24:4:26 | m_y [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:7:56:7:70 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:8:16:10 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:36 | Call [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:36 | new [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:36 | new [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:43 | Call [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:43 | new [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:16:14:16:43 | new [post update] | PostUpdateNode should not be the target of local flow. |
| allocators.cpp:18:1:18:1 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
| assignexpr.cpp:9:4:9:4 | i [post update] | PostUpdateNode should not be the target of local flow. |
| bad_asts.cpp:10:7:10:23 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |

View File

@@ -17,6 +17,24 @@ edges
| test.cpp:38:25:38:42 | (const char *)... | test.cpp:42:14:42:20 | address |
| test.cpp:38:25:38:42 | (const char *)... | test.cpp:42:14:42:20 | address |
| test.cpp:38:25:38:42 | (const char *)... | test.cpp:42:14:42:20 | address indirection |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:52:14:52:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:52:14:52:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:52:14:52:20 | address indirection |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:56:14:56:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:56:14:56:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:56:14:56:20 | address indirection |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:60:14:60:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:60:14:60:20 | address |
| test.cpp:49:25:49:30 | call to getenv | test.cpp:60:14:60:20 | address indirection |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:52:14:52:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:52:14:52:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:52:14:52:20 | address indirection |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:56:14:56:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:56:14:56:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:56:14:56:20 | address indirection |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:60:14:60:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:60:14:60:20 | address |
| test.cpp:49:25:49:42 | (const char *)... | test.cpp:60:14:60:20 | address indirection |
subpaths
nodes
| test.cpp:16:25:16:30 | call to getenv | semmle.label | call to getenv |
@@ -34,7 +52,21 @@ nodes
| test.cpp:42:14:42:20 | address | semmle.label | address |
| test.cpp:42:14:42:20 | address | semmle.label | address |
| test.cpp:42:14:42:20 | address indirection | semmle.label | address indirection |
| test.cpp:49:25:49:30 | call to getenv | semmle.label | call to getenv |
| test.cpp:49:25:49:42 | (const char *)... | semmle.label | (const char *)... |
| test.cpp:52:14:52:20 | address | semmle.label | address |
| test.cpp:52:14:52:20 | address | semmle.label | address |
| test.cpp:52:14:52:20 | address indirection | semmle.label | address indirection |
| test.cpp:56:14:56:20 | address | semmle.label | address |
| test.cpp:56:14:56:20 | address | semmle.label | address |
| test.cpp:56:14:56:20 | address indirection | semmle.label | address indirection |
| test.cpp:60:14:60:20 | address | semmle.label | address |
| test.cpp:60:14:60:20 | address | semmle.label | address |
| test.cpp:60:14:60:20 | address indirection | semmle.label | address indirection |
#select
| test.cpp:20:7:20:12 | call to strcmp | test.cpp:16:25:16:30 | call to getenv | test.cpp:20:14:20:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:16:25:16:30 | call to getenv | call to getenv |
| test.cpp:31:7:31:12 | call to strcmp | test.cpp:27:25:27:30 | call to getenv | test.cpp:31:14:31:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:27:25:27:30 | call to getenv | call to getenv |
| test.cpp:42:7:42:12 | call to strcmp | test.cpp:38:25:38:30 | call to getenv | test.cpp:42:14:42:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:38:25:38:30 | call to getenv | call to getenv |
| test.cpp:52:7:52:12 | call to strcmp | test.cpp:49:25:49:30 | call to getenv | test.cpp:52:14:52:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:49:25:49:30 | call to getenv | call to getenv |
| test.cpp:56:7:56:12 | call to strcmp | test.cpp:49:25:49:30 | call to getenv | test.cpp:56:14:56:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:49:25:49:30 | call to getenv | call to getenv |
| test.cpp:60:7:60:12 | call to strcmp | test.cpp:49:25:49:30 | call to getenv | test.cpp:60:14:60:20 | address | Untrusted input $@ might be vulnerable to a spoofing attack. | test.cpp:49:25:49:30 | call to getenv | call to getenv |

View File

@@ -43,3 +43,27 @@ void processRequest3()
isServer = 1;
}
}
void processRequest4()
{
const char *address = getenv("SERVERIP");
bool cond = false;
if (strcmp(address, "127.0.0.1")) { cond = true; } // BAD
if (strcmp(address, "127_0_0_1")) { cond = true; } // GOOD (not an IP)
if (strcmp(address, "127.0.0")) { cond = true; } // GOOD (not an IP)
if (strcmp(address, "127.0.0.0.1")) { cond = true; } // GOOD (not an IP)
if (strcmp(address, "http://mycompany")) { cond = true; } // BAD
if (strcmp(address, "http_//mycompany")) { cond = true; } // GOOD (not an address)
if (strcmp(address, "htt://mycompany")) { cond = true; } // GOOD (not an address)
if (strcmp(address, "httpp://mycompany")) { cond = true; } // GOOD (not an address)
if (strcmp(address, "mycompany.com")) { cond = true; } // BAD
if (strcmp(address, "mycompany_com")) { cond = true; } // GOOD (not an address)
if (strcmp(address, "mycompany.c")) { cond = true; } // GOOD (not an address)
if (strcmp(address, "mycompany.comm")) { cond = true; } // GOOD (not an address)
if (cond) {
isServer = 1;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Remove operators from the virtualizable type.
compatibility: full

View File

@@ -92,7 +92,8 @@ namespace Semmle.Extraction.CIL.Entities
yield return Tuples.cil_parameter_out(pe);
if (p.Attributes.HasFlag(ParameterAttributes.In))
yield return Tuples.cil_parameter_in(pe);
Attribute.Populate(Context, pe, p.GetCustomAttributes());
foreach (var c in Attribute.Populate(Context, pe, p.GetCustomAttributes()))
yield return c;
}
yield return Tuples.metadata_handle(this, Context.Assembly, MetadataTokens.GetToken(handle));
@@ -205,7 +206,8 @@ namespace Semmle.Extraction.CIL.Entities
yield return Tuples.cil_newslot(this);
// Populate attributes
Attribute.Populate(Context, this, md.GetCustomAttributes());
foreach (var c in Attribute.Populate(Context, this, md.GetCustomAttributes()))
yield return c;
}
}

View File

@@ -0,0 +1,5 @@
---
category: minorAnalysis
---
* Support for `static virtual` and `static abstract` interface members.
* Support for *operators* in interface definitions.

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Attributes on methods in CIL are now extracted (Bugfix).

View File

@@ -129,7 +129,7 @@ pragma[nomagic]
private Virtualizable getACompatibleInterfaceMemberAux(Virtualizable m) {
result = getACompatibleInterfaceAccessor(m) or
result = getACompatibleInterfaceIndexer(m) or
result = getACompatibleInterfaceMethod(m)
result = getACompatibleRelevantInterfaceMember(m)
}
/**
@@ -210,11 +210,13 @@ private predicate getACompatibleInterfaceIndexerAux(Indexer i, ValueOrRefType t)
t = getAPossibleImplementor(i.getDeclaringType())
}
private Method getACompatibleInterfaceMethod0(Method m, int i) {
result = getAnInterfaceMethodCandidate(m) and
private RelevantInterfaceMember getACompatibleRelevantInterfaceMember0(
RelevantInterfaceMember m, int i
) {
result = getARelevantInterfaceMemberCandidate(m) and
i = -1
or
result = getACompatibleInterfaceMethod0(m, i - 1) and
result = getACompatibleRelevantInterfaceMember0(m, i - 1) and
exists(Type t1, Type t2 |
t1 = getArgumentOrReturnType(m, i) and
t2 = getArgumentOrReturnType(result, i)
@@ -223,32 +225,47 @@ private Method getACompatibleInterfaceMethod0(Method m, int i) {
)
}
private Method getACompatibleInterfaceMethod(Method m) {
result = getACompatibleInterfaceMethod0(m, m.getNumberOfParameters())
/**
* A class of callables relevant for interface member compatibility.
*/
private class RelevantInterfaceMember extends Callable {
RelevantInterfaceMember() {
this instanceof Method or
this instanceof Operator
}
predicate isPublic() {
this.(Method).isPublic() or
this.(Operator).isPublic()
}
}
private RelevantInterfaceMember getACompatibleRelevantInterfaceMember(RelevantInterfaceMember m) {
result = getACompatibleRelevantInterfaceMember0(m, m.getNumberOfParameters())
}
/**
* Gets an interface method that may potentially be implemented by `m`.
* Gets an interface method or operator that may potentially be implemented by `m`.
*
* That is, a method with the same name, same number of parameters, and declared
* in a type that is a possible implementor type for the interface type.
*/
private Method getAnInterfaceMethodCandidate(Method m) {
getAPotentialInterfaceMethodAux(result, m.getDeclaringType(), m.getUndecoratedName(),
private RelevantInterfaceMember getARelevantInterfaceMemberCandidate(RelevantInterfaceMember m) {
getAPotentialRelevantInterfaceMemberAux(result, m.getDeclaringType(), m.getUndecoratedName(),
m.getNumberOfParameters()) and
m.isPublic()
}
pragma[nomagic]
private predicate getAPotentialInterfaceMethodAux(
Method m, ValueOrRefType t, string name, int params
private predicate getAPotentialRelevantInterfaceMemberAux(
RelevantInterfaceMember m, ValueOrRefType t, string name, int params
) {
t = getAPossibleImplementor(m.getDeclaringType()) and
name = m.getUndecoratedName() and
params = m.getNumberOfParameters()
}
private Type getArgumentOrReturnType(Method m, int i) {
private Type getArgumentOrReturnType(RelevantInterfaceMember m, int i) {
i = 0 and result = m.getReturnType()
or
result = m.getParameter(i - 1).getType()

View File

@@ -184,7 +184,7 @@ private class TOverridable = @virtualizable or @callable_accessor;
/**
* A declaration that can be overridden or implemented. That is, a method,
* a property, an indexer, an event, or an accessor.
* a property, an indexer, an event, an accessor, or an operator.
*
* Unlike `Virtualizable`, this class includes accessors.
*/
@@ -360,7 +360,7 @@ class Overridable extends Declaration, TOverridable {
/**
* A member where the `virtual` modifier is valid. That is, a method,
* a property, an indexer, or an event.
* a property, an indexer, an event, or an operator.
*
* Equivalently, these are the members that can be defined in an interface.
*

View File

@@ -45,6 +45,16 @@ module Consistency {
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
}
private class RelevantNode extends Node {
@@ -246,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
@@ -254,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."

View File

@@ -670,7 +670,7 @@ compiler_generated(unique int id: @modifiable ref);
@named_exprorstmt = @goto_stmt | @labeled_stmt | @expr;
@virtualizable = @method | @property | @indexer | @event;
@virtualizable = @method | @property | @indexer | @event | @operator;
exprorstmt_name(
unique int parent_id: @named_exprorstmt ref,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Add operators to the virtualizable type.
compatibility: full

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,8 @@ private predicate isOsSpecific(Declaration d) {
.matches("%" +
[
"libobjc", "libproc", "System.Diagnostics.Tracing.XplatEventLogger",
"System.Threading.AutoreleasePool"
"System.Threading.AutoreleasePool",
"System.Diagnostics.Tracing.EventSource.<WriteEventString>"
] + "%")
}

View File

@@ -0,0 +1,34 @@
public interface INumber<T> where T : INumber<T>
{
static abstract T operator ++(T other);
static virtual T operator --(T other) => other;
static abstract T Add(T left, T right);
static virtual T Subtract(T left, T right) => left;
static T Zero() => default(T);
}
public class Complex : INumber<Complex>
{
public double Real { get; private set; } = 0.0;
public double Imaginary { get; private set; } = 0.0;
public Complex() { }
public static Complex Zero() => new Complex();
public static Complex operator ++(Complex other) =>
new Complex { Real = other.Real + 1.0, Imaginary = other.Imaginary };
public static Complex operator --(Complex other) =>
new Complex { Real = other.Real - 1.0, Imaginary = other.Imaginary };
public static Complex Add(Complex left, Complex right) =>
new Complex { Real = left.Real + right.Real, Imaginary = left.Imaginary + right.Imaginary };
public static Complex Subtract(Complex left, Complex right) =>
new Complex { Real = left.Real - right.Real, Imaginary = left.Imaginary - right.Imaginary };
}

View File

@@ -0,0 +1,20 @@
interfacemembers
| INumber<> | StaticInterfaceMembers.cs:3:32:3:33 | ++ | abstract |
| INumber<> | StaticInterfaceMembers.cs:3:32:3:33 | ++ | public |
| INumber<> | StaticInterfaceMembers.cs:3:32:3:33 | ++ | static |
| INumber<> | StaticInterfaceMembers.cs:5:31:5:32 | -- | public |
| INumber<> | StaticInterfaceMembers.cs:5:31:5:32 | -- | static |
| INumber<> | StaticInterfaceMembers.cs:5:31:5:32 | -- | virtual |
| INumber<> | StaticInterfaceMembers.cs:7:23:7:25 | Add | abstract |
| INumber<> | StaticInterfaceMembers.cs:7:23:7:25 | Add | public |
| INumber<> | StaticInterfaceMembers.cs:7:23:7:25 | Add | static |
| INumber<> | StaticInterfaceMembers.cs:9:22:9:29 | Subtract | public |
| INumber<> | StaticInterfaceMembers.cs:9:22:9:29 | Subtract | static |
| INumber<> | StaticInterfaceMembers.cs:9:22:9:29 | Subtract | virtual |
| INumber<> | StaticInterfaceMembers.cs:11:14:11:17 | Zero | public |
| INumber<> | StaticInterfaceMembers.cs:11:14:11:17 | Zero | static |
implements
| StaticInterfaceMembers.cs:23:36:23:37 | ++ | StaticInterfaceMembers.cs:3:32:3:33 | ++ |
| StaticInterfaceMembers.cs:26:36:26:37 | -- | StaticInterfaceMembers.cs:5:31:5:32 | -- |
| StaticInterfaceMembers.cs:29:27:29:29 | Add | StaticInterfaceMembers.cs:7:23:7:25 | Add |
| StaticInterfaceMembers.cs:32:27:32:34 | Subtract | StaticInterfaceMembers.cs:9:22:9:29 | Subtract |

View File

@@ -0,0 +1,18 @@
import csharp
query predicate interfacemembers(string interface, Member m, string modifier) {
exists(Interface i |
i.isUnboundDeclaration() and
i.getFile().getStem() = "StaticInterfaceMembers" and
i.getName() = interface and
m = i.getAMember() and
modifier = m.getAModifier().getName()
)
}
query predicate implements(Overridable o, Virtualizable v) {
v.getFile().getStem() = "StaticInterfaceMembers" and
(v.isVirtual() or v.isAbstract()) and
v.isStatic() and
v.getAnImplementor() = o
}

View File

@@ -7,6 +7,7 @@ type NUL && "%CODEQL_DIST%\codeql" database index-files ^
--include-extension=.xml ^
--size-limit 10m ^
--language xml ^
--working-dir=. ^
-- ^
"%CODEQL_EXTRACTOR_CSHARP_WIP_DATABASE%" ^
>nul 2>&1

View File

@@ -9,6 +9,7 @@ set -eu
--include-extension=.xml \
--size-limit 10m \
--language xml \
--working-dir=. \
-- \
"$CODEQL_EXTRACTOR_CSHARP_WIP_DATABASE" \
> /dev/null 2>&1

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Modified the behaviour of the `go/log-injection` query for `logrus` so that logging functions are not marked as data flow sources if only sanitizing formatters are installed with `SetFormatter` and through the `Formatter` property of `Logger` objects.

View File

@@ -32,7 +32,12 @@ module Logrus {
}
private class LogCall extends LoggerCall::Range, DataFlow::CallNode {
LogCall() { this = any(LogFunction f).getACall() }
LogCall() {
// find calls to logrus logging functions
this = any(LogFunction f).getACall() and
// unless all formatters that get assigned may be sanitizing formatters
not allFormattersMayBeSanitizing()
}
override DataFlow::Node getAMessageComponent() { result = this.getAnArgument() }
}
@@ -49,4 +54,102 @@ module Logrus {
override int getFirstFormattedParameterIndex() { result = argOffset + 1 }
}
private class SetFormatterFunction extends Function {
SetFormatterFunction() {
this.hasQualifiedName(packagePath(), "SetFormatter") or
this.(Method).hasQualifiedName(packagePath(), "Logger", "SetFormatter")
}
}
private class JsonFormatter extends SanitizingFormatter {
JsonFormatter() { this.hasQualifiedName(packagePath(), "JSONFormatter") }
}
/**
* A type which represents a sanitizing formatter for Logrus.
*
* Extend this class to add support for additional, sanitizing formatters.
*/
abstract class SanitizingFormatter extends Type { }
/**
* An assignment statement that assigns a value to the `Formatter` property of a `Logger` object.
*/
private class SetFormatterAssignment extends AssignStmt {
int lhsIndex;
SetFormatterAssignment() {
exists(Field field |
this.getLhs(lhsIndex).(SelectorExpr).uses(field) and
field.hasQualifiedName(packagePath(), "Logger", "Formatter")
)
}
/**
* Gets the formatter that is being assigned to the `Formatter` property.
*/
Expr getFormatter() { result = this.getRhs(lhsIndex) }
}
/**
* Holds if there is local data flow to `node` that, at some point, has a sanitizing formatter
* type.
*/
private predicate mayBeSanitizingFormatter(DataFlow::Node node) {
// is there data flow from something of a sanitizing formatter type to the node?
exists(DataFlow::Node source |
// this is a slight approximation since a variable could be set to a
// sanitizing formatter and then replaced with another one that isn't
DataFlow::localFlow(source, node) and
source.getType() = any(SanitizingFormatter f).getPointerType()
)
}
/**
* Holds if `node` is the first argument to a call to the `SetFormatter` function or if `node`
* is the value being assigned to the `Formatter` property of a `Logger` object. The `expr`
* is the corresponding expression (the function call or the rhs of the assignment).
*/
private predicate isFormatter(DataFlow::Node node, Expr expr) {
exists(DataFlow::CallNode call |
call = any(SetFormatterFunction f).getACall() and
node = call.getArgument(0) and
expr = call.asExpr()
)
or
expr = any(SetFormatterAssignment stmt).getFormatter() and
node.asExpr() = expr
}
/**
* Holds if `expr` is conditional within its enclosing function and there are no other formatter
* assignments in the same function.
*/
private predicate isSoleConditional(Expr expr) {
exists(FuncDef func |
// find the enclosing function
func = expr.getEnclosingFunction() and
// check that the expression is conditional
expr.getParent*() instanceof IfStmt and
// and there isn't another formatter assignment in the function
not exists(Expr formatterAssignment |
isFormatter(_, formatterAssignment) and
formatterAssignment.getEnclosingFunction() = func and
expr != formatterAssignment
)
)
}
/**
* Holds if all calls to `SetFormatter` have a sanitizing formatter as argument and all
* assignments to the `Formatter` property of `Logger` values are also sanitizing formatters.
* Also holds if there are not any calls to `SetFormatter` or assignments to the `Formatter`
* property in the codebase.
*/
private predicate allFormattersMayBeSanitizing() {
forex(DataFlow::Node node, Expr expr | isFormatter(node, expr) |
mayBeSanitizingFormatter(node) and not isSoleConditional(expr)
)
}
}

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,31 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,27 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func initLogger(useJSON bool) {
if useJSON {
logrus.SetFormatter(&logrus.JSONFormatter{})
} else {
// another safe formatter
logrus.SetFormatter(&logrus.JSONFormatter{})
}
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,31 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.TextFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,32 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
textFormatter := new(logrus.TextFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = textFormatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,31 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.TextFormatter{})
formatter := new(logrus.JSONFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,32 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
textFormatter := new(logrus.TextFormatter)
logrus.SetFormatter(textFormatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,31 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.TextFormatter{})
logger.SetFormatter(formatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,32 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
formatter := new(logrus.JSONFormatter)
textFormatter := new(logrus.TextFormatter)
logrus.SetFormatter(formatter)
logger := logrus.StandardLogger()
logger.SetFormatter(&logrus.JSONFormatter{})
logger.SetFormatter(textFormatter)
logger.Formatter = &logrus.JSONFormatter{}
logger.Formatter = formatter
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

View File

@@ -0,0 +1,11 @@
import go
import TestUtilities.InlineFlowTest
import semmle.go.security.LogInjection
class LogInjectionTest extends InlineFlowTest {
override DataFlow::Configuration getTaintFlowConfig() {
result = any(LogInjection::Configuration config)
}
override DataFlow::Configuration getValueFlowConfig() { none() }
}

View File

@@ -0,0 +1,8 @@
module main
go 1.14
require (
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
github.com/sirupsen/logrus v1.8.1
)

View File

@@ -0,0 +1,24 @@
package main
//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,Logger,JSONFormatter,TextFormatter SetFormatter,StandardLogger,WithFields
//go:generate depstubber -vendor github.com/elazarl/goproxy ProxyCtx ""
import (
"net/http"
"github.com/elazarl/goproxy"
"github.com/sirupsen/logrus"
)
func initLogger(useJSON bool) {
if useJSON {
logrus.SetFormatter(&logrus.JSONFormatter{})
}
}
func logUserData(req *http.Request, ctx *goproxy.ProxyCtx) {
username := req.URL.Query()["username"][0]
logrus.WithFields(logrus.Fields{ // $ hasTaintFlow="map literal"
"USERNAME": username,
})
}

View File

@@ -0,0 +1,125 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/elazarl/goproxy, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/elazarl/goproxy (exports: ProxyCtx; functions: )
// Package goproxy is a stub of github.com/elazarl/goproxy, generated by depstubber.
package goproxy
import (
tls "crypto/tls"
net "net"
http "net/http"
)
type CertStorage interface {
Fetch(_ string, _ func() (*tls.Certificate, error)) (*tls.Certificate, error)
}
type ConnectAction struct {
Action ConnectActionLiteral
Hijack func(*http.Request, net.Conn, *ProxyCtx)
TLSConfig func(string, *ProxyCtx) (*tls.Config, error)
}
type ConnectActionLiteral int
type HttpsHandler interface {
HandleConnect(_ string, _ *ProxyCtx) (*ConnectAction, string)
}
type Logger interface {
Printf(_ string, _ ...interface{})
}
type ProxyConds struct{}
func (_ *ProxyConds) Do(_ RespHandler) {}
func (_ *ProxyConds) DoFunc(_ func(*http.Response, *ProxyCtx) *http.Response) {}
type ProxyCtx struct {
Req *http.Request
Resp *http.Response
RoundTripper RoundTripper
Error error
UserData interface{}
Session int64
Proxy *ProxyHttpServer
}
func (_ *ProxyCtx) Charset() string {
return ""
}
func (_ *ProxyCtx) Logf(_ string, _ ...interface{}) {}
func (_ *ProxyCtx) RoundTrip(_ *http.Request) (*http.Response, error) {
return nil, nil
}
func (_ *ProxyCtx) Warnf(_ string, _ ...interface{}) {}
type ProxyHttpServer struct {
KeepDestinationHeaders bool
Verbose bool
Logger Logger
NonproxyHandler http.Handler
Tr *http.Transport
ConnectDial func(string, string) (net.Conn, error)
ConnectDialWithReq func(*http.Request, string, string) (net.Conn, error)
CertStore CertStorage
KeepHeader bool
}
func (_ *ProxyHttpServer) NewConnectDialToProxy(_ string) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) NewConnectDialToProxyWithHandler(_ string, _ func(*http.Request)) func(string, string) (net.Conn, error) {
return nil
}
func (_ *ProxyHttpServer) OnRequest(_ ...ReqCondition) *ReqProxyConds {
return nil
}
func (_ *ProxyHttpServer) OnResponse(_ ...RespCondition) *ProxyConds {
return nil
}
func (_ *ProxyHttpServer) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {}
type ReqCondition interface {
HandleReq(_ *http.Request, _ *ProxyCtx) bool
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type ReqHandler interface {
Handle(_ *http.Request, _ *ProxyCtx) (*http.Request, *http.Response)
}
type ReqProxyConds struct{}
func (_ *ReqProxyConds) Do(_ ReqHandler) {}
func (_ *ReqProxyConds) DoFunc(_ func(*http.Request, *ProxyCtx) (*http.Request, *http.Response)) {}
func (_ *ReqProxyConds) HandleConnect(_ HttpsHandler) {}
func (_ *ReqProxyConds) HandleConnectFunc(_ func(string, *ProxyCtx) (*ConnectAction, string)) {}
func (_ *ReqProxyConds) HijackConnect(_ func(*http.Request, net.Conn, *ProxyCtx)) {}
type RespCondition interface {
HandleResp(_ *http.Response, _ *ProxyCtx) bool
}
type RespHandler interface {
Handle(_ *http.Response, _ *ProxyCtx) *http.Response
}
type RoundTripper interface {
RoundTrip(_ *http.Request, _ *ProxyCtx) (*http.Response, error)
}

View File

@@ -0,0 +1,357 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for github.com/sirupsen/logrus, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: github.com/sirupsen/logrus (exports: Fields,Logger,JSONFormatter,TextFormatter; functions: SetFormatter,StandardLogger,WithFields)
// Package logrus is a stub of github.com/sirupsen/logrus, generated by depstubber.
package logrus
import (
bytes "bytes"
context "context"
io "io"
runtime "runtime"
time "time"
)
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer *bytes.Buffer
Context context.Context
}
func (_ Entry) HasCaller() bool {
return false
}
func (_ *Entry) Bytes() ([]byte, error) {
return nil, nil
}
func (_ *Entry) Debug(_ ...interface{}) {}
func (_ *Entry) Debugf(_ string, _ ...interface{}) {}
func (_ *Entry) Debugln(_ ...interface{}) {}
func (_ *Entry) Dup() *Entry {
return nil
}
func (_ *Entry) Error(_ ...interface{}) {}
func (_ *Entry) Errorf(_ string, _ ...interface{}) {}
func (_ *Entry) Errorln(_ ...interface{}) {}
func (_ *Entry) Fatal(_ ...interface{}) {}
func (_ *Entry) Fatalf(_ string, _ ...interface{}) {}
func (_ *Entry) Fatalln(_ ...interface{}) {}
func (_ *Entry) Info(_ ...interface{}) {}
func (_ *Entry) Infof(_ string, _ ...interface{}) {}
func (_ *Entry) Infoln(_ ...interface{}) {}
func (_ *Entry) Log(_ Level, _ ...interface{}) {}
func (_ *Entry) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Entry) Logln(_ Level, _ ...interface{}) {}
func (_ *Entry) Panic(_ ...interface{}) {}
func (_ *Entry) Panicf(_ string, _ ...interface{}) {}
func (_ *Entry) Panicln(_ ...interface{}) {}
func (_ *Entry) Print(_ ...interface{}) {}
func (_ *Entry) Printf(_ string, _ ...interface{}) {}
func (_ *Entry) Println(_ ...interface{}) {}
func (_ *Entry) String() (string, error) {
return "", nil
}
func (_ *Entry) Trace(_ ...interface{}) {}
func (_ *Entry) Tracef(_ string, _ ...interface{}) {}
func (_ *Entry) Traceln(_ ...interface{}) {}
func (_ *Entry) Warn(_ ...interface{}) {}
func (_ *Entry) Warnf(_ string, _ ...interface{}) {}
func (_ *Entry) Warning(_ ...interface{}) {}
func (_ *Entry) Warningf(_ string, _ ...interface{}) {}
func (_ *Entry) Warningln(_ ...interface{}) {}
func (_ *Entry) Warnln(_ ...interface{}) {}
func (_ *Entry) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Entry) WithError(_ error) *Entry {
return nil
}
func (_ *Entry) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Entry) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Entry) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Entry) Writer() *io.PipeWriter {
return nil
}
func (_ *Entry) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
type FieldMap map[interface{}]string
type Fields map[string]interface{}
type Formatter interface {
Format(_ *Entry) ([]byte, error)
}
type Hook interface {
Fire(_ *Entry) error
Levels() []Level
}
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
PrettyPrint bool
}
func (_ *JSONFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
type Level uint32
func (_ Level) MarshalText() ([]byte, error) {
return nil, nil
}
func (_ Level) String() string {
return ""
}
func (_ *Level) UnmarshalText(_ []byte) error {
return nil
}
type LevelHooks map[Level][]Hook
func (_ LevelHooks) Add(_ Hook) {}
func (_ LevelHooks) Fire(_ Level, _ *Entry) error {
return nil
}
type LogFunction func() []interface{}
type Logger struct {
Out io.Writer
Hooks LevelHooks
Formatter Formatter
ReportCaller bool
Level Level
ExitFunc interface{}
}
func (_ *Logger) AddHook(_ Hook) {}
func (_ *Logger) Debug(_ ...interface{}) {}
func (_ *Logger) DebugFn(_ LogFunction) {}
func (_ *Logger) Debugf(_ string, _ ...interface{}) {}
func (_ *Logger) Debugln(_ ...interface{}) {}
func (_ *Logger) Error(_ ...interface{}) {}
func (_ *Logger) ErrorFn(_ LogFunction) {}
func (_ *Logger) Errorf(_ string, _ ...interface{}) {}
func (_ *Logger) Errorln(_ ...interface{}) {}
func (_ *Logger) Exit(_ int) {}
func (_ *Logger) Fatal(_ ...interface{}) {}
func (_ *Logger) FatalFn(_ LogFunction) {}
func (_ *Logger) Fatalf(_ string, _ ...interface{}) {}
func (_ *Logger) Fatalln(_ ...interface{}) {}
func (_ *Logger) GetLevel() Level {
return 0
}
func (_ *Logger) Info(_ ...interface{}) {}
func (_ *Logger) InfoFn(_ LogFunction) {}
func (_ *Logger) Infof(_ string, _ ...interface{}) {}
func (_ *Logger) Infoln(_ ...interface{}) {}
func (_ *Logger) IsLevelEnabled(_ Level) bool {
return false
}
func (_ *Logger) Log(_ Level, _ ...interface{}) {}
func (_ *Logger) LogFn(_ Level, _ LogFunction) {}
func (_ *Logger) Logf(_ Level, _ string, _ ...interface{}) {}
func (_ *Logger) Logln(_ Level, _ ...interface{}) {}
func (_ *Logger) Panic(_ ...interface{}) {}
func (_ *Logger) PanicFn(_ LogFunction) {}
func (_ *Logger) Panicf(_ string, _ ...interface{}) {}
func (_ *Logger) Panicln(_ ...interface{}) {}
func (_ *Logger) Print(_ ...interface{}) {}
func (_ *Logger) PrintFn(_ LogFunction) {}
func (_ *Logger) Printf(_ string, _ ...interface{}) {}
func (_ *Logger) Println(_ ...interface{}) {}
func (_ *Logger) ReplaceHooks(_ LevelHooks) LevelHooks {
return nil
}
func (_ *Logger) SetFormatter(_ Formatter) {}
func (_ *Logger) SetLevel(_ Level) {}
func (_ *Logger) SetNoLock() {}
func (_ *Logger) SetOutput(_ io.Writer) {}
func (_ *Logger) SetReportCaller(_ bool) {}
func (_ *Logger) Trace(_ ...interface{}) {}
func (_ *Logger) TraceFn(_ LogFunction) {}
func (_ *Logger) Tracef(_ string, _ ...interface{}) {}
func (_ *Logger) Traceln(_ ...interface{}) {}
func (_ *Logger) Warn(_ ...interface{}) {}
func (_ *Logger) WarnFn(_ LogFunction) {}
func (_ *Logger) Warnf(_ string, _ ...interface{}) {}
func (_ *Logger) Warning(_ ...interface{}) {}
func (_ *Logger) WarningFn(_ LogFunction) {}
func (_ *Logger) Warningf(_ string, _ ...interface{}) {}
func (_ *Logger) Warningln(_ ...interface{}) {}
func (_ *Logger) Warnln(_ ...interface{}) {}
func (_ *Logger) WithContext(_ context.Context) *Entry {
return nil
}
func (_ *Logger) WithError(_ error) *Entry {
return nil
}
func (_ *Logger) WithField(_ string, _ interface{}) *Entry {
return nil
}
func (_ *Logger) WithFields(_ Fields) *Entry {
return nil
}
func (_ *Logger) WithTime(_ time.Time) *Entry {
return nil
}
func (_ *Logger) Writer() *io.PipeWriter {
return nil
}
func (_ *Logger) WriterLevel(_ Level) *io.PipeWriter {
return nil
}
func SetFormatter(_ Formatter) {}
func StandardLogger() *Logger {
return nil
}
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (string, string)
}
func (_ *TextFormatter) Format(_ *Entry) ([]byte, error) {
return nil, nil
}
func WithFields(_ Fields) *Entry {
return nil
}

View File

@@ -0,0 +1,6 @@
# github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819
## explicit
github.com/elazarl/goproxy
# github.com/sirupsen/logrus v1.8.1
## explicit
github.com/sirupsen/logrus

Some files were not shown because too many files have changed in this diff Show More