pack

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNewPack added in v0.0.3

func GenerateNewPack(cli *codeql.CLI, opts GeneratePackOptions) error

GenerateNewPack creates a new CodeQL query with scaffolding. It checks whether a pack with the same full name already exists via ListPacks unless args.Overwrite is true; in that case it returns an error.

func GetPackName added in v0.0.3

func GetPackName(packName string) string

GetPackName returns the name part after the scope.

func GetPackScope added in v0.0.3

func GetPackScope(packName string) string

GetPackScope returns the scope part of the pack name (before "/").

func RunAnalyze added in v0.0.3

func RunAnalyze(base, database, packRef string, format, output string, threads int) error

RunAnalyze runs `codeql database analyze` using the resolved query pack directory as the analysis target (all queries in that pack).

Types

type GeneratePackOptions added in v0.0.3

type GeneratePackOptions struct {
	Base            string
	QueryName       string
	Lang            string
	Pack            string
	QueryKind       string
	CreateQueryPack bool
	CreateTests     bool
	Overwrite       bool
	UseBundle       bool
	Library         bool
}

GeneratePackOptions holds all arguments for the pack generate new-query command.

type Pack

type Pack struct {
	YmlPath string
	Config  QlpackConfig
	Deps    []*Pack
}

Pack is a resolved CodeQL pack.

func ListPacks

func ListPacks(cli *codeql.CLI, dir string) ([]*Pack, error)

ListPacks runs `codeql pack ls --format=json <dir>` and returns all packs found.

func SelectPacks added in v0.1.0

func SelectPacks(allPacks []*Pack, names []string, skipTest bool) ([]*Pack, error)

SelectPacks resolves a list of pack names against allPacks. Names match by full name first, then by unique short name (segment after "/"). When names is empty, every pack is returned (filtered by skipTest). When skipTest is true, test packs are excluded from both the empty-filter result and from short/full name matching.

func (*Pack) CachePath

func (p *Pack) CachePath() string

CachePath returns the path to the .cache/ directory.

func (*Pack) CopyTo

func (p *Pack) CopyTo(destRoot string) (*Pack, error)

func (*Pack) CustomizationsPath

func (p *Pack) CustomizationsPath() string

CustomizationsPath returns the expected path for Customizations.qll.

func (*Pack) DepsPath

func (p *Pack) DepsPath() string

DepsPath returns the path to the .codeql/ installed-dependencies directory.

func (*Pack) Dir

func (p *Pack) Dir() string

Dir returns the directory containing qlpack.yml.

func (*Pack) IsCustomizable

func (p *Pack) IsCustomizable() bool

IsCustomizable returns true if Customizations.qll already exists in the pack dir.

func (*Pack) IsTestPack

func (p *Pack) IsTestPack() bool

IsTestPack returns true if the pack is a test pack, identified by either having an extractor field set or being located under a test/ directory.

func (*Pack) LockFilePath

func (p *Pack) LockFilePath() string

LockFilePath returns the path to codeql-pack.lock.yml.

func (*Pack) SaveConfig

func (p *Pack) SaveConfig(updates map[string]interface{}) error

SaveConfig writes the in-memory qlpack.yml back to disk, preserving existing fields not tracked by QlpackConfig.

type PackKind

type PackKind int

PackKind classifies a CodeQL pack.

const (
	QueryPack         PackKind = iota
	LibraryPack       PackKind = iota
	CustomizationPack PackKind = iota
)

type QlpackConfig

type QlpackConfig struct {
	Name         string            `yaml:"name"`
	Version      string            `yaml:"version"`
	Library      bool              `yaml:"library"`
	Dependencies map[string]string `yaml:"dependencies"`
	Extractor    string            `yaml:"extractor"`
}

QlpackConfig holds the fields from qlpack.yml that qlt cares about.

func (*QlpackConfig) FullName

func (c *QlpackConfig) FullName() string

func (*QlpackConfig) HasExtractor

func (c *QlpackConfig) HasExtractor() bool

HasExtractor returns true if the pack has an extractor field set.

func (*QlpackConfig) ModuleName

func (c *QlpackConfig) ModuleName() string

ModuleName converts "foo/cpp-customizations" → "foo.cpp_customizations" for use in QL import statements.

func (*QlpackConfig) PackName

func (c *QlpackConfig) PackName() string

PackName returns the name part after the scope.

func (*QlpackConfig) Scope

func (c *QlpackConfig) Scope() string

Scope returns the scope part of the pack name (before "/").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL