parser

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupportedFile = errors.New("unsupported file to parse")

ErrNotSupportedFile represents an error when a file is not supported by the scanner

Functions

func IsLineInfoOnly added in v1.17.0

func IsLineInfoOnly(ctx context.Context) bool

IsLineInfoOnly reports whether ctx was marked with WithLineInfoOnly.

func WithLineInfoOnly added in v1.17.0

func WithLineInfoOnly(ctx context.Context) context.Context

WithLineInfoOnly marks a parse as a reparse that only needs the document's line markers, so parsers may skip enrichment that only rules consume.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is a representation of parsers that will be construct

func NewBuilder

func NewBuilder(ctx context.Context) *Builder

NewBuilder creates a new Builder's reference

func (*Builder) Add

func (b *Builder) Add(p kindParser) *Builder

Add is a function that adds a new parser to the caller and returns it

func (*Builder) Build

func (b *Builder) Build(types, cloudProviders []string) ([]*Parser, error)

Build prepares parsers and associates a parser to its extension and returns it

func (*Builder) WithFS added in v1.7.0

func (b *Builder) WithFS(fsys vfs.FS) *Builder

WithFS sets the filesystem used for extension detection during parsing. The CLI omits it (defaults to the real disk); the HTTP server injects an in-memory FS so pushed content (not on disk) is recognized. A nil fsys is ignored.

type ParsedDocument

type ParsedDocument struct {
	Docs          []model.Document
	Kind          model.FileKind
	Content       string
	IgnoreLines   []int
	CountLines    int
	ResolvedFiles map[string]model.ResolvedFile
	IsMinified    bool
	// DirectoryDependent marks parses whose output depends on sibling files
	// (see directoryDependentParser); the runner must not share them across
	// files with identical content.
	DirectoryDependent bool
}

ParsedDocument is a struct containing data retrieved from parsing

type Parser

type Parser struct {
	// Parsers is public because necessary for testing purposes
	Parsers kindParser

	Platform []string
	SCIInfo  model.SCIInfo
	// contains filtered or unexported fields
}

Parser is a struct that associates a parser to its supported extensions

func (*Parser) CommentsCommands

func (c *Parser) CommentsCommands(ctx context.Context, filePath string, fileContent []byte) model.CommentsCommands

CommentsCommands gets commands on comments in the file beginning, before the code starts

func (*Parser) FS added in v1.7.0

func (c *Parser) FS() vfs.FS

FS returns the filesystem used for extension detection. The HTTP server injects an in-memory FS for pushed content; the CLI defaults to the real disk. Never returns nil so callers can use it directly.

func (*Parser) Parse

func (c *Parser) Parse(
	ctx context.Context,
	filePath string,
	fileContent []byte,
	openAPIResolveReferences, isMinified bool,
	maxResolverDepth int) (ParsedDocument, error)

Parse executes a parser on the fileContent and returns the file content as a Document, the file kind and an error, if an error has occurred

func (*Parser) ParseContent added in v1.14.0

func (c *Parser) ParseContent(
	ctx context.Context,
	filePath string,
	fileContent []byte,
	openAPIResolveReferences, isMinified bool,
	maxResolverDepth int) (ParsedDocument, error)

ParseContent uses the selected parser regardless of the file extension.

func (*Parser) SupportedExtensions

func (c *Parser) SupportedExtensions() model.Extensions

SupportedExtensions returns extensions supported by the scanner

Directories

Path Synopsis
ansible
ini/comments
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
ini/config
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
ini/hosts
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
converter
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
jsonfilter
parser
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
comment
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
converter
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
functions
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
modules
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
modules/modulegraph
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
modules/moduleprepare
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
modules/resolver
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
tfeval
Package tfeval evaluates local Terraform modules: bind inputs, resolve locals, recurse into nested modules, emit resources with concrete cty values where possible.
Package tfeval evaluates local Terraform modules: bind inputs, resolve locals, recurse into nested modules, emit resources with concrete cty values where possible.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
cicd
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
default
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
dockercompose
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
dockercompose/names
Package names holds the default Docker Compose file names as a leaf package, shared by the Compose parser and the analyzer's classifier (which sit on opposite sides of an import cycle through pkg/parser/yaml), so both agree on which files are base files and which are auto-merged overrides.
Package names holds the default Docker Compose file names as a leaf package, shared by the Compose parser and the analyzer's classifier (which sit on opposite sides of an import cycle through pkg/parser/yaml), so both agree on which files are base files and which are auto-merged overrides.

Jump to

Keyboard shortcuts

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