lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430319507-1869-1-git-send-email-valentinrothberg@gmail.com>
Date:	Wed, 29 Apr 2015 16:58:27 +0200
From:	Valentin Rothberg <valentinrothberg@...il.com>
To:	valentinrothberg@...il.com, gregkh@...uxfoundation.org,
	stefan.hengelein@....de, linux-kernel@...r.kernel.org,
	pebolle@...cali.nl
Subject: [PATCH] checkkconfigsymbols.py: add option -i to ignore files

Sometimes a user might be interested to filter certain reports (e.g.,
the many defconfigs).  Now, this can be achieved by specifying a Python
regex with -i / --ignore.

Signed-off-by: Valentin Rothberg <valentinrothberg@...il.com>
---
 scripts/checkkconfigsymbols.py | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index 74086a583d8d..f35c8ac5d9a0 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -58,6 +58,12 @@ def parse_options():
                            "input format bases on Git log's "
                            "\'commmit1..commit2\'.")
 
+    parser.add_option('-i', '--ignore', dest='ignore', action='store',
+                      default="",
+                      help="Ignore files matching this pattern.  Note that "
+                           "the pattern needs to be a Python regex.  To "
+                           "ignore defconfigs, specify -i '.*defconfig'.")
+
     parser.add_option('', '--force', dest='force', action='store_true',
                       default=False,
                       help="Reset current Git tree even when it's dirty.")
@@ -80,6 +86,12 @@ def parse_options():
                      "'--force' if you\nwant to ignore this warning and "
                      "continue.")
 
+    if opts.ignore:
+        try:
+            re.match(opts.ignore, "this/is/just/a/test.c")
+        except:
+            sys.exit("Please specify a valid Python regex.")
+
     return opts
 
 
@@ -105,11 +117,11 @@ def main():
 
         # get undefined items before the commit
         execute("git reset --hard %s" % commit_a)
-        undefined_a = check_symbols()
+        undefined_a = check_symbols(opts.ignore)
 
         # get undefined items for the commit
         execute("git reset --hard %s" % commit_b)
-        undefined_b = check_symbols()
+        undefined_b = check_symbols(opts.ignore)
 
         # report cases that are present for the commit but not before
         for feature in sorted(undefined_b):
@@ -129,7 +141,7 @@ def main():
 
     # default to check the entire tree
     else:
-        undefined = check_symbols()
+        undefined = check_symbols(opts.ignore)
         for feature in sorted(undefined):
             files = sorted(undefined.get(feature))
             print "%s\t%s" % (feature, ", ".join(files))
@@ -160,9 +172,10 @@ def get_head():
     return stdout.strip('\n')
 
 
-def check_symbols():
+def check_symbols(ignore):
     """Find undefined Kconfig symbols and return a dict with the symbol as key
-    and a list of referencing files as value."""
+    and a list of referencing files as value.  Files matching %ignore are not
+    checked for undefined symbols."""
     source_files = []
     kconfig_files = []
     defined_features = set()
@@ -185,10 +198,17 @@ def check_symbols():
             source_files.append(gitfile)
 
     for sfile in source_files:
+        if ignore and re.match(ignore, sfile):
+            # do not check files matching %ignore
+            continue
         parse_source_file(sfile, referenced_features)
 
     for kfile in kconfig_files:
-        parse_kconfig_file(kfile, defined_features, referenced_features)
+        if ignore and re.match(ignore, kfile):
+            # do not collect references for files matching %ignore
+            parse_kconfig_file(kfile, defined_features, dict())
+        else:
+            parse_kconfig_file(kfile, defined_features, referenced_features)
 
     undefined = {}  # {feature: [files]}
     for feature in sorted(referenced_features):
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ