summaryrefslogtreecommitdiff
path: root/.lgtm
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2018-10-26 09:19:09 +0000
committerLennart Poettering <lennart@poettering.net>2018-10-26 12:27:43 +0200
commitf86c1da28340f2a2afd34d72c9f416a2a94219a8 (patch)
tree174350548dc0c6354e2773cd0ae2d0de95fdfe7f /.lgtm
parent9f1c81d80a435d15ca1bd536a6d043c18c81c047 (diff)
downloadsystemd-f86c1da28340f2a2afd34d72c9f416a2a94219a8.tar.gz
lgtm: add a custom query for catching the use of fgets
As everybody knows, nodoby really reads CODING_STYLE (especially the last paragraph :-)) so let's utilize LGTM to help us catch the use of fgets.
Diffstat (limited to '.lgtm')
-rw-r--r--.lgtm/cpp-queries/fgets.ql23
1 files changed, 23 insertions, 0 deletions
diff --git a/.lgtm/cpp-queries/fgets.ql b/.lgtm/cpp-queries/fgets.ql
new file mode 100644
index 0000000000..82de8c4482
--- /dev/null
+++ b/.lgtm/cpp-queries/fgets.ql
@@ -0,0 +1,23 @@
+/**
+ * @name Use of fgets()
+ * @description fgets() is dangerous to call. Use read_line() instead.
+ * @kind problem
+ * @problem.severity error
+ * @precision high
+ * @id cpp/fgets
+ * @tags reliability
+ * security
+ */
+import cpp
+
+
+predicate dangerousFunction(Function function) {
+ exists (string name | name = function.getQualifiedName() |
+ name = "fgets")
+}
+
+
+from FunctionCall call, Function target
+where call.getTarget() = target
+ and dangerousFunction(target)
+select call, target.getQualifiedName() + " is potentially dangerous"