mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Golang vendor dir extraction: add extractor option
This commit is contained in:
@@ -27,3 +27,10 @@ options:
|
||||
The default is 'false'.
|
||||
type: string
|
||||
pattern: "^(false|true)$"
|
||||
extract_vendor_dirs:
|
||||
title: Whether to include Go vendor directories in the CodeQL database.
|
||||
description: >
|
||||
A value indicating whether Go vendor directories should be included in the CodeQL database.
|
||||
The default is 'false'.
|
||||
type: string
|
||||
pattern: "^(false|true)$"
|
||||
|
||||
@@ -233,7 +233,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
|
||||
// Construct a list of directory segments to exclude from extraction, starting with ".."
|
||||
excludedDirs := []string{`\.\.`}
|
||||
|
||||
// If CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
|
||||
// If CODEQL_EXTRACTOR_GO_[OPTION_]EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
|
||||
// otherwise (the default) is to exclude them from extraction
|
||||
includeVendor := util.IsVendorDirExtractionEnabled()
|
||||
if !includeVendor {
|
||||
|
||||
@@ -5,5 +5,6 @@ import (
|
||||
)
|
||||
|
||||
func IsVendorDirExtractionEnabled() bool {
|
||||
return os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS") == "true"
|
||||
return os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS") == "true" ||
|
||||
os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS") == "true"
|
||||
}
|
||||
|
||||
@@ -4,3 +4,6 @@ import os
|
||||
def test(codeql, go):
|
||||
os.environ["CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS"] = "true"
|
||||
codeql.database.create(source_root="src")
|
||||
|
||||
def test_extractor_option(codeql, go):
|
||||
codeql.database.create(source_root="src", extractor_option = "extract_vendor_dirs=true")
|
||||
|
||||
Reference in New Issue
Block a user