From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 6C3C6AC1819 for ; Thu, 2 Nov 2023 20:03:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zgtHQpLH0w0XxDHdMwn4EMUaFcLCKKnfNHvF+uJPyog=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698955428; v=1; b=R0dWiCqMtVNTdPBqxPfVoyiILvLuAEhb1urlV6qojk9fA0VhCb2lNKl1UcUeTo8fNbnJbnNn TadUBmM2JmviqmpXyOFl5kZHrZEhuGm2eBS/3jZ7mpRD8X48xDrCz+szGdaDQ1Um/Igqete+vRC O3UY4PVl9VGfw7RgoBZ5Fuyk= X-Received: by 127.0.0.2 with SMTP id iyIdYY7687511xa6vAWOMi9j; Thu, 02 Nov 2023 13:03:48 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.42416.1698955427617992819 for ; Thu, 02 Nov 2023 13:03:47 -0700 X-Received: from localhost.localdomain (unknown [47.201.241.95]) by linux.microsoft.com (Postfix) with ESMTPSA id B3D1F20B74C1; Thu, 2 Nov 2023 13:03:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B3D1F20B74C1 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Sean Brogan , Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH v4 4/8] .pytool/CISettings.py: Integrate CodeQL Date: Thu, 2 Nov 2023 16:03:08 -0400 Message-ID: <20231102200313.1010-5-mikuback@linux.microsoft.com> In-Reply-To: <20231102200313.1010-1-mikuback@linux.microsoft.com> References: <20231102200313.1010-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kLZOyAVbcRWUpGfIqFiG88Hux7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=R0dWiCqM; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Michael Kubacki Adds the `--codeql` parameter to `stuart_update` and `stuart_ci_build`. - `stuart_update --codeql` - Downloads the CodeQL CLI locally. The command will pull the appropriate binary for the host OS. - `stuart_ci_build --codeql` - Runs CodeQL during the build resulting in a CodeQL database and SARIF result file in the `Build` directory. Cc: Sean Brogan Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Michael Kubacki Acked-by: Michael D Kinney --- .pytool/CISettings.py | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index c5803a877c36..b8b8080439c1 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -7,12 +7,27 @@ ## import os import logging +import sys from edk2toolext.environment import shell_environment from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager from edk2toolext.invocables.edk2_setup import SetupSettingsManager, Requ= iredSubmodule from edk2toolext.invocables.edk2_update import UpdateSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toollib.utility_functions import GetHostInfo +from pathlib import Path + + +try: + # Temporarily needed until edk2 can update to the latest edk2-pytool= s + # that has the CodeQL helpers. + # + # May not be present until submodules are populated. + # + root =3D Path(__file__).parent.parent.resolve() + sys.path.append(str(root/'BaseTools'/'Plugin'/'CodeQL'/'integration'= )) + import stuart_codeql as codeql_helpers +except ImportError: + pass =20 =20 class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSetti= ngsManager, PrEvalSettingsManager): @@ -34,6 +49,11 @@ class Settings(CiBuildSettingsManager, UpdateSettingsM= anager, SetupSettingsManag group.add_argument("-force_piptools", "--fpt", dest=3D"force_pip= tools", action=3D"store_true", default=3DFalse, help=3D"Force the system = to use pip tools") group.add_argument("-no_piptools", "--npt", dest=3D"no_piptools"= , action=3D"store_true", default=3DFalse, help=3D"Force the system to not= use pip tools") =20 + try: + codeql_helpers.add_command_line_option(parserObj) + except NameError: + pass + def RetrieveCommandLineOptions(self, args): super().RetrieveCommandLineOptions(args) if args.force_piptools: @@ -41,6 +61,11 @@ class Settings(CiBuildSettingsManager, UpdateSettingsM= anager, SetupSettingsManag if args.no_piptools: self.UseBuiltInBaseTools =3D False =20 + try: + self.codeql =3D codeql_helpers.is_codeql_enabled_on_command_= line(args) + except NameError: + pass + # ##################################################################= ##################### # # Default Support for this Ci Build = # # ##################################################################= ##################### # @@ -169,6 +194,11 @@ class Settings(CiBuildSettingsManager, UpdateSetting= sManager, SetupSettingsManag else: logging.warning("Falling back to using in-tree BaseTools= ") =20 + try: + scopes +=3D codeql_helpers.get_scopes(self.codeql) + except NameError: + pass + self.ActualScopes =3D scopes return self.ActualScopes =20 --=20 2.42.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110569): https://edk2.groups.io/g/devel/message/110569 Mute This Topic: https://groups.io/mt/102350793/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-