diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.expected b/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.expected new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql b/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql new file mode 100644 index 00000000000..05b18540aed --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/LoggerCall.ql @@ -0,0 +1,17 @@ +import go +import TestUtilities.InlineExpectationsTest + +class LoggerTest extends InlineExpectationsTest { + LoggerTest() { this = "LoggerTest" } + + override string getARelevantTag() { result = "logger" } + + override predicate hasActualResult(string file, int line, string element, string tag, string value) { + exists(LoggerCall log | + log.hasLocationInfo(file, line, _, _, _) and + element = log.toString() and + value = log.getAMessageComponent().toString() and + tag = "logger" + ) + } +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/glog.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/glog.go new file mode 100644 index 00000000000..f73e44fa7bd --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/glog.go @@ -0,0 +1,53 @@ +//go:generate depstubber -vendor github.com/golang/glog "" Error,ErrorDepth,Errorf,Errorln,Exit,ExitDepth,Exitf,Exitln,Fatal,FatalDepth,Fatalf,Fatalln,Info,InfoDepth,Infof,Infoln,Warning,WarningDepth,Warningf,Warningln +//go:generate depstubber -vendor k8s.io/klog "" Error,ErrorDepth,Errorf,Errorln,Exit,ExitDepth,Exitf,Exitln,Fatal,FatalDepth,Fatalf,Fatalln,Info,InfoDepth,Infof,Infoln,Warning,WarningDepth,Warningf,Warningln + +package main + +import ( + "github.com/golang/glog" + "k8s.io/klog" +) + +func glogTest() { + glog.Error(text) // $logger=text + glog.ErrorDepth(0, text) // $f-:logger=text + glog.Errorf(fmt, text) // $logger=fmt $logger=text + glog.Errorln(text) // $logger=text + glog.Exit(text) // $logger=text + glog.ExitDepth(0, text) // $f-:logger=text + glog.Exitf(fmt, text) // $logger=fmt $logger=text + glog.Exitln(text) // $logger=text + glog.Fatal(text) // $logger=text + glog.FatalDepth(0, text) // $f-:logger=text + glog.Fatalf(fmt, text) // $logger=fmt $logger=text + glog.Fatalln(text) // $logger=text + glog.Info(text) // $logger=text + glog.InfoDepth(0, text) // $f-:logger=text + glog.Infof(fmt, text) // $logger=fmt $logger=text + glog.Infoln(text) // $logger=text + glog.Warning(text) // $logger=text + glog.WarningDepth(0, text) // $f-:logger=text + glog.Warningf(fmt, text) // $logger=fmt $logger=text + glog.Warningln(text) // $logger=text + + klog.Error(text) // $logger=text + klog.ErrorDepth(0, text) // $f-:logger=text + klog.Errorf(fmt, text) // $logger=fmt $logger=text + klog.Errorln(text) // $logger=text + klog.Exit(text) // $logger=text + klog.ExitDepth(0, text) // $f-:logger=text + klog.Exitf(fmt, text) // $logger=fmt $logger=text + klog.Exitln(text) // $logger=text + klog.Fatal(text) // $logger=text + klog.FatalDepth(0, text) // $f-:logger=text + klog.Fatalf(fmt, text) // $logger=fmt $logger=text + klog.Fatalln(text) // $logger=text + klog.Info(text) // $logger=text + klog.InfoDepth(0, text) // $f-:logger=text + klog.Infof(fmt, text) // $logger=fmt $logger=text + klog.Infoln(text) // $logger=text + klog.Warning(text) // $logger=text + klog.WarningDepth(0, text) // $f-:logger=text + klog.Warningf(fmt, text) // $logger=fmt $logger=text + klog.Warningln(text) // $logger=text +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/go.mod b/ql/test/library-tests/semmle/go/concepts/LoggerCall/go.mod new file mode 100644 index 00000000000..81d2785a409 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/go.mod @@ -0,0 +1,9 @@ +module codeql-go-tests/concepts/loggercall + +go 1.15 + +require ( + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b + github.com/sirupsen/logrus v1.7.0 + k8s.io/klog v1.0.0 +) diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/logrus.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/logrus.go new file mode 100644 index 00000000000..c2e65ff6788 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/logrus.go @@ -0,0 +1,34 @@ +//go:generate depstubber -vendor github.com/sirupsen/logrus Fields,LogFunction,Entry WithContext,WithError,WithFields,Error,Fatalf,Panicln,Infof,FatalFn + +package main + +import ( + "context" + "errors" + "github.com/sirupsen/logrus" +) + +func logSomething(entry *logrus.Entry) { + entry.Traceln(text) // $logger=text $f-:logger=fields +} + +func logrusCalls() { + err := errors.New("Error") + var fields logrus.Fields = nil + var fn logrus.LogFunction = nil + var ctx context.Context + tmp := logrus.WithContext(ctx) // + tmp.Debugf(fmt, text) // $logger=ctx $logger=fmt $logger=text + tmp = logrus.WithError(err) // + tmp.Warn(text) // $logger=err $logger=text + tmp = logrus.WithFields(fields) // + tmp.Infoln(text) // $logger=fields $logger=text + tmp = logrus.WithFields(fields) // + logSomething(tmp) + + logrus.Error(text) // $logger=text + logrus.Fatalf(fmt, text) // $logger=fmt $logger=text + logrus.Panicln(text) // $logger=text + logrus.Infof(fmt, text) // $logger=fmt $logger=text + logrus.FatalFn(fn) // $logger=fn +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/main.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/main.go new file mode 100644 index 00000000000..bb2111afbec --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/main.go @@ -0,0 +1,8 @@ +package main + +const fmt = "formatted %s string" +const text = "test" + +func main() { + +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/stdlib.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/stdlib.go new file mode 100644 index 00000000000..22e2e5de3d5 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/stdlib.go @@ -0,0 +1,30 @@ +package main + +import ( + "log" +) + +func stdlib() { + var logger log.Logger + logger.SetPrefix("prefix: ") + logger.Fatal(text) // $logger=text + logger.Fatalf(fmt, text) // $logger=fmt $logger=text + logger.Fatalln(text) // $logger=text + logger.Panic(text) // $logger=text + logger.Panicf(fmt, text) // $logger=fmt $logger=text + logger.Panicln(text) // $logger=text + logger.Print(text) // $logger=text + logger.Printf(fmt, text) // $logger=fmt $logger=text + logger.Println(text) // $logger=text + + log.SetPrefix("prefix: ") + log.Fatal(text) // $logger=text + log.Fatalf(fmt, text) // $logger=fmt $logger=text + log.Fatalln(text) // $logger=text + log.Panic(text) // $logger=text + log.Panicf(fmt, text) // $logger=fmt $logger=text + log.Panicln(text) // $logger=text + log.Print(text) // $logger=text + log.Printf(fmt, text) // $logger=fmt $logger=text + log.Println(text) // $logger=text +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/LICENSE b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/LICENSE new file mode 100644 index 00000000000..37ec93a14fd --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/stub.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/stub.go new file mode 100644 index 00000000000..7c4ffefc1e8 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/stub.go @@ -0,0 +1,50 @@ +// Code generated by depstubber. DO NOT EDIT. +// This is a simple stub for github.com/golang/glog, strictly for use in testing. + +// See the LICENSE file for information about the licensing of the original library. +// Source: github.com/golang/glog (exports: ; functions: Error,ErrorDepth,Errorf,Errorln,Exit,ExitDepth,Exitf,Exitln,Fatal,FatalDepth,Fatalf,Fatalln,Info,InfoDepth,Infof,Infoln,Warning,WarningDepth,Warningf,Warningln) + +// Package glog is a stub of github.com/golang/glog, generated by depstubber. +package glog + +import () + +func Error(_ ...interface{}) {} + +func ErrorDepth(_ int, _ ...interface{}) {} + +func Errorf(_ string, _ ...interface{}) {} + +func Errorln(_ ...interface{}) {} + +func Exit(_ ...interface{}) {} + +func ExitDepth(_ int, _ ...interface{}) {} + +func Exitf(_ string, _ ...interface{}) {} + +func Exitln(_ ...interface{}) {} + +func Fatal(_ ...interface{}) {} + +func FatalDepth(_ int, _ ...interface{}) {} + +func Fatalf(_ string, _ ...interface{}) {} + +func Fatalln(_ ...interface{}) {} + +func Info(_ ...interface{}) {} + +func InfoDepth(_ int, _ ...interface{}) {} + +func Infof(_ string, _ ...interface{}) {} + +func Infoln(_ ...interface{}) {} + +func Warning(_ ...interface{}) {} + +func WarningDepth(_ int, _ ...interface{}) {} + +func Warningf(_ string, _ ...interface{}) {} + +func Warningln(_ ...interface{}) {} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/LICENSE b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/LICENSE new file mode 100644 index 00000000000..f090cb42f37 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Simon Eskildsen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/stub.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/stub.go new file mode 100644 index 00000000000..edca56aa803 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/sirupsen/logrus/stub.go @@ -0,0 +1,327 @@ +// 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,LogFunction,Entry; functions: WithContext,WithError,WithFields,Error,Fatalf,Panicln,Infof,FatalFn) + +// 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) 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 +} + +func Error(_ ...interface{}) {} + +func FatalFn(_ LogFunction) {} + +func Fatalf(_ string, _ ...interface{}) {} + +type Fields map[string]interface{} + +type Formatter interface { + Format(_ *Entry) ([]byte, error) +} + +type Hook interface { + Fire(_ *Entry) error + Levels() []Level +} + +func Infof(_ string, _ ...interface{}) {} + +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 Panicln(_ ...interface{}) {} + +func WithContext(_ context.Context) *Entry { + return nil +} + +func WithError(_ error) *Entry { + return nil +} + +func WithFields(_ Fields) *Entry { + return nil +} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/LICENSE b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/LICENSE new file mode 100644 index 00000000000..37ec93a14fd --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/stub.go b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/stub.go new file mode 100644 index 00000000000..d0357248812 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/stub.go @@ -0,0 +1,50 @@ +// Code generated by depstubber. DO NOT EDIT. +// This is a simple stub for k8s.io/klog, strictly for use in testing. + +// See the LICENSE file for information about the licensing of the original library. +// Source: k8s.io/klog (exports: ; functions: Error,ErrorDepth,Errorf,Errorln,Exit,ExitDepth,Exitf,Exitln,Fatal,FatalDepth,Fatalf,Fatalln,Info,InfoDepth,Infof,Infoln,Warning,WarningDepth,Warningf,Warningln) + +// Package klog is a stub of k8s.io/klog, generated by depstubber. +package klog + +import () + +func Error(_ ...interface{}) {} + +func ErrorDepth(_ int, _ ...interface{}) {} + +func Errorf(_ string, _ ...interface{}) {} + +func Errorln(_ ...interface{}) {} + +func Exit(_ ...interface{}) {} + +func ExitDepth(_ int, _ ...interface{}) {} + +func Exitf(_ string, _ ...interface{}) {} + +func Exitln(_ ...interface{}) {} + +func Fatal(_ ...interface{}) {} + +func FatalDepth(_ int, _ ...interface{}) {} + +func Fatalf(_ string, _ ...interface{}) {} + +func Fatalln(_ ...interface{}) {} + +func Info(_ ...interface{}) {} + +func InfoDepth(_ int, _ ...interface{}) {} + +func Infof(_ string, _ ...interface{}) {} + +func Infoln(_ ...interface{}) {} + +func Warning(_ ...interface{}) {} + +func WarningDepth(_ int, _ ...interface{}) {} + +func Warningf(_ string, _ ...interface{}) {} + +func Warningln(_ ...interface{}) {} diff --git a/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/modules.txt b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/modules.txt new file mode 100644 index 00000000000..c20671b4194 --- /dev/null +++ b/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/modules.txt @@ -0,0 +1,14 @@ +# github.com/github/depstubber v0.0.0-20200916130315-f3217697abd4 +## explicit +# github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b +## explicit +github.com/golang/glog +# github.com/sirupsen/logrus v1.7.0 +## explicit +github.com/sirupsen/logrus +# golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 +golang.org/x/sys/unix +golang.org/x/sys/windows +# k8s.io/klog v1.0.0 +## explicit +k8s.io/klog