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 6C55B7803CD for ; Mon, 16 Oct 2023 20:13:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TXicd3KpSiIdH81/+2yQVfFSjLdFg8ofujUcRv6iNRM=; 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=1697487194; v=1; b=wr4gtAjO1Ww81NBV7KQf28Q+laIfmr077cpEMt9BXMCuyBeWucuJWnAq6rRLTz4fGuZh5/Yn rzBfp+rVK/uPQx25RcNEGchYaeLEFe71Kd2E6mfsxcKSrrDXg2bEBOF9kcPymG1t7ljIhYhgB3y IGfBvNUIl39/0LaEAooPahL4= X-Received: by 127.0.0.2 with SMTP id el0QYY7687511xf8SexP7igG; Mon, 16 Oct 2023 13:13:14 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.178593.1697487193596662515 for ; Mon, 16 Oct 2023 13:13:13 -0700 X-Received: from localhost.localdomain (unknown [47.201.241.95]) by linux.microsoft.com (Postfix) with ESMTPSA id BA2BA20B74C0; Mon, 16 Oct 2023 13:13:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BA2BA20B74C0 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Sean Brogan , Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH v2 4/7] .pytool/CISettings.py: Integrate CodeQL Date: Mon, 16 Oct 2023 16:12:35 -0400 Message-ID: <20231016201239.953-5-mikuback@linux.microsoft.com> In-Reply-To: <20231016201239.953-1-mikuback@linux.microsoft.com> References: <20231016201239.953-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: Z88E3aVzFyHnODffGpYkqAZQx7686176AA= 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=wr4gtAjO; 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 --- .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 (#109650): https://edk2.groups.io/g/devel/message/109650 Mute This Topic: https://groups.io/mt/102004565/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-