Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeQL Stuart parameter to this repo #136

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .pytool/CISettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
import glob
import os
import logging
import sys
from edk2toolext.environment import shell_environment
from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager
from edk2toolext.invocables.edk2_setup import SetupSettingsManager
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:
# May not be present until submodules are populated
root = Path(__file__).parent.parent.resolve()
sys.path.append(str(root / 'MU_BASECORE' / '.pytool' / 'Plugin' / 'CodeQL' / 'integration'))
import stuart_codeql as codeql_helpers
except ImportError:
pass


class Settings(
Expand Down Expand Up @@ -52,13 +63,23 @@ def AddCommandLineOptions(self, parserObj):
help="Force the system to not use pip tools",
)

try:
codeql_helpers.add_command_line_option(parserObj)
except NameError:
pass

def RetrieveCommandLineOptions(self, args):
super().RetrieveCommandLineOptions(args)
if args.force_piptools:
self.UseBuiltInBaseTools = True
if args.no_piptools:
self.UseBuiltInBaseTools = False

try:
self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args)
except NameError:
pass

# ####################################################################################### #
# Default Support for this Ci Build #
# ####################################################################################### #
Expand Down Expand Up @@ -169,7 +190,28 @@ def GetActiveScopes(self):
scopes += ("gcc_arm_linux",)
if "RISCV64" in self.ActualArchitectures:
scopes += ("gcc_riscv64_unknown",)

try:
scopes += codeql_helpers.get_scopes(self.codeql)

if self.codeql:
shell_environment.GetBuildVars().SetValue(
"STUART_CODEQL_AUDIT_ONLY",
"TRUE",
"Set in CISettings.py")
codeql_filter_files = [str(n) for n in glob.glob(
os.path.join(self.GetWorkspaceRoot(),
'**/CodeQlFilters.yml'),
recursive=True)]
shell_environment.GetBuildVars().SetValue(
"STUART_CODEQL_FILTER_FILES",
','.join(codeql_filter_files),
"Set in CISettings.py")
except NameError:
pass

self.ActualScopes = scopes

return self.ActualScopes

def GetRequiredSubmodules(self):
Expand Down