]> sourceware.org Git - annobin.git/commitdiff
10.92: Annocheck: Try harder not to run mutually exclusive tests
authorNick Clifton <nickc@redhat.com>
Mon, 7 Nov 2022 17:50:54 +0000 (17:50 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 7 Nov 2022 17:50:54 +0000 (17:50 +0000)
12 files changed:
annobin-global.h
annocheck/annocheck.c
annocheck/annocheck.h
annocheck/built-by.c
annocheck/hardened.c
annocheck/libannocheck.h
annocheck/notes.c
annocheck/size.c
annocheck/timing.c
configure
configure.ac
meson.build

index 9bd82b052d469f6ffba200d4e03bcfab1ad7cfc6..e0259ff5cba23feb44ffa8e382fb7218ddc7fe38 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
    NB/ Keep this value in sync with LIBANNOCHECK_VERSION defined in
    annocheck/libannocheck.h and with 'version' defined in meson.build,
    and with ANNOBIN_VERSION defined in configure.ac.  */
-#define ANNOBIN_VERSION 1091
+#define ANNOBIN_VERSION 1092
 
 /* The version of the annotation specification supported.  */
 #define SPEC_VERSION  3
index ed8870f6d28e2b7acbd8187512359ad50a9c5b32..fb06216b5e8b86b4b22250c793c586bdec4d3b0d 100644 (file)
@@ -189,6 +189,7 @@ einfo (einfo_type type, const char * format, ...)
   const char *  do_newline;
   char          c;
   size_t        len = strlen (format);
+
   if (len < 1)
     fatal ("einfo called without a valid format string");
   c = format[len - 1];
@@ -214,6 +215,7 @@ einfo (einfo_type type, const char * format, ...)
 
   if (type != PARTIAL)
     fprintf (file, "%s", do_newline);
+
   return res;
 #endif
 }
@@ -1904,17 +1906,17 @@ create_tmpdir (void)
 }
 
 static void
-print_version (void)
+print_version (int level)
 {
-  einfo (INFO, "Version %d.%02d", ANNOBIN_VERSION / 100, ANNOBIN_VERSION % 100);
+  if (level < 1)
+    einfo (INFO, "Version %d.%02d", ANNOBIN_VERSION / 100, ANNOBIN_VERSION % 100);
 
   checker * tool;
   for (tool = first_checker; tool != NULL; tool = ((checker_internal *)(tool->internal))->next)
     if (tool->version)
       {
        push_component (tool);
-       einfo (PARTIAL, " ");
-       tool->version ();
+       tool->version (level);
        pop_component ();
       }
 }
@@ -2253,7 +2255,7 @@ process_command_line (uint argc, const char * argv[])
                }
              else if (streq (arg, "version"))
                {
-                 print_version ();
+                 print_version (-1);
                  exit (EXIT_SUCCESS);
                }
              else
@@ -2338,8 +2340,7 @@ main (int argc, const char ** argv)
   if (! process_command_line (argc, argv))
     return EXIT_FAILURE;
 
-  if (level == 0)
-    einfo (INFO, "Version %d.%02d", ANNOBIN_VERSION / 100, ANNOBIN_VERSION % 100);
+  print_version (level);
   
   for (tool = first_checker; tool != NULL; tool = ((checker_internal *)(tool->internal))->next)
     if (tool->start_scan != NULL)
index 49de8484a7b724629754841d09099015c8938dd7..3f368e89f23504290ca2e6a47a1c303ff1dc2e50 100644 (file)
@@ -1,5 +1,5 @@
 /* Annocheck - A tool for checking security features of binares.
-   Copyright (c) 2018 - 2019 Red Hat.
+   Copyright (c) 2018 - 2022 Red Hat.
 
   This is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
@@ -143,10 +143,13 @@ typedef struct checker
      Should use einfo to display its information.  */
   void (* usage) (void);
 
-  /* Called to display the version of the checker.
+  /* Called to display the version of the checker.  Called after command line arguments
+     have been processed, but before start_scan is called.
      Can be NULL.
-     Should use einfo to display its information.  */
-  void (* version) (void);
+     Should use einfo to display its information.
+     LEVEL is the recursion level.  A level of -1 indicates that the function is
+     being called in response to the --version option on the command line.  */
+  void (* version) (int level);
 
   /* Called at the start of a scan of a set of input files for a given recursion depth.
      Called after PROCESS_ARG has been invoked, if that function is not NULL.
index 24ca8571f995ad66abda8ee81aac5df21b872386..653928aca4c4ad3451a7ed90b6c8c306dc7d38c0 100644 (file)
@@ -1,5 +1,5 @@
 /* Checks the builder of the binary file. 
-   Copyright (c) 2018 - 2020 Red Hat.
+   Copyright (c) 2018 - 2022 Red Hat.
 
   This is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
@@ -394,9 +394,10 @@ builtby_usage (void)
 }
 
 static void
-builtby_version (void)
+builtby_version (int level)
 {
-  einfo (INFO, "Version 1.1");
+  if (level == -1)
+    einfo (INFO, "Version 1.1");
 }
 
 struct checker builtby_checker = 
index 10db87105a58308d2203e08097e6feea67fa0ac4..f1629c45199298750d3b706264d5899fed31c6fa 100644 (file)
@@ -2025,13 +2025,15 @@ dwarf_attribute_checker (annocheck_data *  data,
 
 static const struct profiles
 {
-  const char *      name[MAX_NAMES];
+  const char *      name[MAX_NAMES]; /* Note: name[0] is used as the name of the profile in output statements.  */
   const char *      file_suffix[MAX_NAMES];
   enum  test_index  disabled_tests[MAX_DISABLED];
   enum  test_index  enabled_tests[MAX_DISABLED];
 }
   profiles [PROFILE_MAX] =
 {
+  [ PROFILE_NONE ] = { { "none" } },
+  
   [ PROFILE_EL7 ] = { { "el7", "rhel-7" }, 
                      {".el7" },
                      { TEST_BRANCH_PROTECTION, TEST_DYNAMIC_TAGS, TEST_PIE, TEST_BIND_NOW, TEST_FORTIFY, TEST_STACK_CLASH, TEST_LTO, TEST_ENTRY, TEST_PROPERTY_NOTE, TEST_CF_PROTECTION },
@@ -2047,7 +2049,7 @@ static const struct profiles
                      { TEST_BRANCH_PROTECTION, TEST_DYNAMIC_TAGS },
                      { TEST_NOT_BRANCH_PROTECTION, TEST_NOT_DYNAMIC_TAGS } },
 
-  [ PROFILE_RAWHIDE ] = { { "rawhide", "f37" },
+  [ PROFILE_RAWHIDE ] = { { "rawhide", "f37", "fedora" },
                          { ".fc38", ".fc37" },
                          { TEST_NOT_BRANCH_PROTECTION, TEST_NOT_DYNAMIC_TAGS },
                          { TEST_BRANCH_PROTECTION, TEST_DYNAMIC_TAGS } },
@@ -2125,25 +2127,6 @@ make_profile_based_changes (enum profile profile)
          break;
        }
     }
-
-  /* Handle mutually exclusive tests.  */
-  if (tests [TEST_BRANCH_PROTECTION].enabled && tests [TEST_NOT_BRANCH_PROTECTION].enabled)
-    {
-#ifdef AARCH64_BRANCH_PROTECTION_SUPPORTED
-      tests [TEST_NOT_BRANCH_PROTECTION].enabled = false;
-#else
-      tests [TEST_BRANCH_PROTECTION].enabled = false;
-#endif
-    }
-
-  if (tests [TEST_DYNAMIC_TAGS].enabled && tests [TEST_NOT_DYNAMIC_TAGS].enabled)
-    {
-#ifdef AARCH64_BRANCH_PROTECTION_SUPPORTED
-      tests [TEST_NOT_DYNAMIC_TAGS].enabled = false;
-#else
-      tests [TEST_DYNAMIC_TAGS].enabled = false;
-#endif
-    }
 }
 
 static enum profile
@@ -2176,7 +2159,7 @@ get_profile_based_upon_filename (annocheck_data * data)
 
          if (strstr (filename, suffix) != NULL)
            {
-             einfo (VERBOSE, "%s: info: selecting profile %s",
+             einfo (VERBOSE, "%s: info: selecting profile '%s' based upon filename",
                     get_filename (data), profiles[i].name[0]);
              return i;
            }
@@ -2215,6 +2198,25 @@ start (annocheck_data * data)
       tests [i].skipped = false;
     }
 
+  /* Handle mutually exclusive tests.  */
+  if (tests [TEST_BRANCH_PROTECTION].enabled && tests [TEST_NOT_BRANCH_PROTECTION].enabled)
+    {
+#ifdef AARCH64_BRANCH_PROTECTION_SUPPORTED
+      tests [TEST_NOT_BRANCH_PROTECTION].enabled = false;
+#else
+      tests [TEST_BRANCH_PROTECTION].enabled = false;
+#endif
+    }
+
+  if (tests [TEST_DYNAMIC_TAGS].enabled && tests [TEST_NOT_DYNAMIC_TAGS].enabled)
+    {
+#ifdef AARCH64_BRANCH_PROTECTION_SUPPORTED
+      tests [TEST_NOT_DYNAMIC_TAGS].enabled = false;
+#else
+      tests [TEST_DYNAMIC_TAGS].enabled = false;
+#endif
+    }
+  
   /* Initialise other per-file variables.  */
   memset (& per_file, 0, sizeof per_file);
 
@@ -5828,9 +5830,15 @@ finish (annocheck_data * data)
 }
 
 static void
-version (void)
+version (int level)
 {
-  einfo (INFO, "Version 1.5");
+  if (level == -1)
+    einfo (INFO, "Version 1.6");
+  else if (level == 0)
+    {
+      if (selected_profile >= PROFILE_NONE && selected_profile < PROFILE_MAX)
+       einfo (INFO, "using profile: %s", profiles [selected_profile].name[0]);
+    }
 }
 
 static void
@@ -6128,7 +6136,7 @@ process_arg (const char * arg, const char ** argv, const uint argc, uint * next)
                }
            }
 
-         einfo (ERROR, "Argument to --profile- option not recognised");
+         einfo (ERROR, "Argument to --profile option not recognised");
        }
 
       /* Consume the argument so that the annocheck framework does not mistake it for the -p option.  */
@@ -6342,7 +6350,14 @@ libannocheck_enable_all_tests (libannocheck_internals_ptr handle)
   unsigned int i;
 
   for (i = 0; i < TEST_MAX; i++)
-    handle->tests[i].enabled = true;
+    {
+      // Do not enable the negative tests.
+      if (i == TEST_NOT_BRANCH_PROTECTION
+         || i == TEST_NOT_DYNAMIC_TAGS)
+       continue;
+
+      handle->tests[i].enabled = true;
+    }
 
   return libannocheck_error_none;
 }
index 9ad3601d85cf193137de6b4087a66dbd3a7f914b..13bd422db9b24024ce56d4ab604210bd7551ade0 100644 (file)
@@ -23,7 +23,7 @@ extern "C" {
 
 /* NB/ Keep this value in sync with ANNOBIN_VERSION defined in
    annobin-global.h.  */
-#define LIBANNOCHECK_VERSION 1091
+#define LIBANNOCHECK_VERSION 1092
 
 typedef enum libannocheck_error
 {
index 217b70c1a73ec742bf4337e368e390259bab4c85..47489681a04782ff208d9e64132a85fb3e75baef 100644 (file)
@@ -1,5 +1,5 @@
 /* Displays the Annobin notes in binary files.
-   Copyright (c) 2019-2021 Red Hat.
+   Copyright (c) 2019-2022 Red Hat.
 
   This is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
@@ -684,9 +684,10 @@ notes_usage (void)
 }
 
 static void
-notes_version (void)
+notes_version (int level)
 {
-  einfo (INFO, "Version 1.0");
+  if (level == -1)
+    einfo (INFO, "Version 1.0");
 }
 
 struct checker notes_checker = 
index 15403b59860006b7c54be4d92f4bab41641c4919..fe17ecfd49bc0bd0d5eb94114113943b0510f669 100644 (file)
@@ -481,9 +481,10 @@ size_usage (void)
 }
 
 static void
-size_version (void)
+size_version (int level)
 {
-  einfo (INFO, "Version 1.3");
+  if (level == -1)
+    einfo (INFO, "Version 1.3");
 }
 
 struct checker size_checker = 
index b2e26f5431ed28026772d22ed46abfe9033df494..c5b64dbf4e99381817edd41b2c2e7a7147809275 100644 (file)
@@ -1,5 +1,5 @@
 /* Monitors the time annocheck takes running its tools.
-   Copyright (c) 2018 - 2021 Red Hat.
+   Copyright (c) 2018 - 2022 Red Hat.
 
   This is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
@@ -242,9 +242,10 @@ timing_usage (void)
 }
 
 static void
-timing_version (void)
+timing_version (int level)
 {
-  einfo (INFO, "Version 1.0");
+  if (level == -1)
+    einfo (INFO, "Version 1.0");
 }
 
 struct checker timing_checker = 
index 2b0fc29d6b4ad514e76a397e6618a1e3eb22120a..653ff530cf10bf6a3448f8baef80bacf718a8b6b 100755 (executable)
--- a/configure
+++ b/configure
@@ -2701,7 +2701,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
 
-ANNOBIN_VERSION=10.90
+ANNOBIN_VERSION=10.92
 
 
 # Make sure we can run config.sub.
index 6f66f629a117d6f7b3290f35c45d86b57fdee42c..af694f36e5e2addd593fe721e8f84a06b018477b 100644 (file)
@@ -7,7 +7,7 @@ AC_INIT([Binary Annotations], 10.0,,[annobin-plugin])
 AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_SRCDIR([annobin-global.h])
 
-ANNOBIN_VERSION=10.91
+ANNOBIN_VERSION=10.92
 AC_SUBST(ANNOBIN_VERSION)
 
 AC_CANONICAL_SYSTEM
index d4127b157f249d3dd90f96c75004ef5b31967950..4a55d74cd4eb960ff95e729b702b0b5456ece9db 100644 (file)
@@ -1,7 +1,7 @@
 project(
   'annobin',
   ['c', 'cpp'],
-  version: '10.91',
+  version: '10.92',
   meson_version: '>=0.59'
 )
 
This page took 0.085629 seconds and 5 git commands to generate.