semgrep の API リファレンス
semgrep (semgrep/semgrep) の公開 API 173 件 —— クラス 68、関数 73、メソッド 32。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: semgrep/semgrep
| 種別 | 件数 |
|---|---|
| クラス | 68 |
| 関数 | 73 |
| メソッド | 32 |
API 一覧
func
cli.src.semdep.golang_version.cmp_golang_versions(parsed_version:ParsedGolangVersion, specifier_version:ParsedGolangVersion) -> intCompares the package version and the spec version.
func
cli.src.semdep.golang_version.compare_golang_specifier(specifier:str, version:str) -> boolReturns if version satisfies specifier arguments
class
cli.src.semdep.matchers.base.ManifestOnlyMatcherA matcher for lone manifests.
class
cli.src.semdep.matchers.gradle.GradleMatcherMatcher for gradle project root directories.
func
cli.src.semdep.maven_version.compare_maven_specifier(specifier:str, version:str) -> boolReturns if version satisfies specifier requirement i.e.
func
cli.src.semdep.parsers.pnpm.get_key_values(yaml:YamlTree[YamlMap], field:str) -> List[str]Extracts all keys from a specified field in a YamlMap.
func
cli.src.semdep.parsers.pnpm.parse_dependency_version(version_str:str) -> ParseResultParses a dependency version string into its components.
func
cli.src.semdep.parsers.pnpm.parse_direct_pre_v6(yaml:YamlTree[YamlMap]) -> List[str]Extracts direct dependencies for pnpm-lock.yaml version <=5.4.
func
cli.src.semdep.parsers.pnpm.parse_package_key_post_v9(key:str) -> Optional[Tuple[str, str]]Parses the package key for pnpm-lock.yaml version >=9.0.
func
cli.src.semdep.parsers.pnpm.parse_package_key_pre_v6(key:str) -> Optional[Tuple[str, str]]Parses the package key for pnpm-lock.yaml version <=5.4.
class
cli.src.semdep.parsers.util.ParsedDependencyA dependency parsed from a lockfile.
func
cli.src.semdep.parsers.util.become(p1:Parser[A], p2:Parser[A]) -> NoneGives [p1] the behavior of [p2] by side effect.
func
cli.src.semdep.parsers.util.not_any(*chars:str) -> Parser[str][chars] must contain only single character strings.
func
cli.src.semdep.parsers.util.quoted(p:Parser[A]) -> Parser[A]Parse [p], surrounded by quotes, ignoring the quotes in the output
func
cli.src.semdep.parsers.util.to_parser(parser:LegacyDependencyParser) -> DependencyParserConverts a legacy parser to a new parser format.
func
cli.src.semdep.parsers.util.upto(*include_other:bool=False, *consume_other:bool=False, *allow_newline:bool=False, *s:str) -> Parser[str][s] must be a list of single character strings.
func
cli.src.semdep.parsers.yarn.get_manifest_deps(parsed_manifest:Optional[JSON]) -> Optional[Set[Tuple[str, str]]]Extract a set of constraints from a package.json file
func
cli.src.semgrep.app.auth.set_token(token:str) -> NoneSave api token to settings file
class
cli.src.semgrep.app.session.AppSessionSend requests to Semgrep App with this session.
class
cli.src.semgrep.app.session.UserAgentGenerates the user agent string we send to Semgrep App.
class
cli.src.semgrep.commands.scan.ScanResultThe return type of the scan function
method
cli.src.semgrep.config_resolver.ConfigLoader.includes_remote_config(configs:Optional[Sequence[str]]) -> boolReturns True if any of the configs are remote
method
cli.src.semgrep.config_resolver.ConfigLoader.load_config() -> List[ConfigFile]Loads a config based on self's state.
class
cli.src.semgrep.config_resolver.ParsedConfigResult of parsing a single config string into rules.
func
cli.src.semgrep.config_resolver.is_registry_id(config_str:str) -> boolStarts with r/, p/, s/ for registry, pack, and snippet respectively
func
cli.src.semgrep.config_resolver.read_config_at_path(loc:Path, base_path:Optional[Path]=None) -> ConfigFileAssumes file at loc exists
func
cli.src.semgrep.config_resolver.registry_id_to_url(registry_id:str) -> strConvert from registry_id to semgrep.dev url
func
cli.src.semgrep.core_runner.parse_core_output_json(output_json:Any) -> out.CoreOutputConvert JSON tree into CoreOutput and import profiling data
class
cli.src.semgrep.error.DependencyResolutionSemgrepErrorAn error that occurred during dependency resolution.
class
cli.src.semgrep.error_handler.ErrorHandlerSend scan status to the fail-open endpoint
method
cli.src.semgrep.error_handler.ErrorHandler.configure(suppress_errors:Optional[bool]=False) -> NoneConfigures whether to always or never send fail-open status.
method
cli.src.semgrep.error_handler.ErrorHandler.is_enabled() -> boolReturns whether scan status should be sent.
method
cli.src.semgrep.error_handler.ErrorHandler.send(exit_code:int) -> intSend scan status to the fail-open server.
class
cli.src.semgrep.error_location.PositionPosition within a file.
class
cli.src.semgrep.error_location.SpanSpans are immutable objects, representing segments of code.
method
cli.src.semgrep.error_location.Span.with_context(before:Optional[int]=None, after:Optional[int]=None) -> 'Span'Expand
func
cli.src.semgrep.formatter.text.to_severity_indicator(rule_match:RuleMatch, color_output:bool=False) -> Tuple[str, str]Return a color and severity icon.
func
cli.src.semgrep.git.is_git_repo_empty() -> boolChecks if the repo is empty.
func
cli.src.semgrep.git.zsplit(s:str) -> List[str]Split a string on null characters.
func
cli.src.semgrep.join_rule.create_config_map(semgrep_config_strings:List[str]) -> Dict[str, Rule]Create a mapping of Semgrep config strings to Rule objects.
func
cli.src.semgrep.join_rule.run_join_rule(join_rule:Dict[str, Any], scanning_roots:List[Path], fips_mode:bool, allow_local_builds:bool=False, ptt_enabled:bool=False) -> Tuple[List[RuleMatch], List[SemgrepError]]Run a 'join' mode rule.
class
cli.src.semgrep.mcp.hooks.inject_secure_defaults.EmptyStdinErrorException raised when the stdin is empty.
func
cli.src.semgrep.mcp.hooks.inject_secure_defaults.fetch_readme() -> strFetch the README from GitHub and cache it.
func
cli.src.semgrep.mcp.hooks.inject_secure_defaults.get_cached_content() -> str | NoneGet content from cache if available.
func
cli.src.semgrep.mcp.hooks.inject_secure_defaults.get_fallback_content() -> strReturn fallback content if GitHub fetch fails.
func
cli.src.semgrep.mcp.hooks.stop.load_file_path() -> tuple[str, str]Returns the file path and the workspace root
func
cli.src.semgrep.mcp.server.get_deployment_slug() -> strFetches and caches the deployment slug from Semgrep API.
func
cli.src.semgrep.mcp.server.get_semgrep_rule_yaml(rule_id:str=RULE_ID_FIELD) -> strFull Semgrep rule in YAML format from the Semgrep registry.
func
cli.src.semgrep.mcp.server.health(request:Request) -> JSONResponseHealth check endpoint
func
cli.src.semgrep.mcp.server.semgrep_whoami(ctx:Context) -> WhoamiResultReturns the identity of the current user.
func
cli.src.semgrep.mcp.server.server_lifespan(_server:FastMCP) -> AsyncIterator[SemgrepContext]Manage server startup and shutdown lifecycle.
func
cli.src.semgrep.mcp.server.validate_absolute_path(path_to_validate:str, param_name:str) -> strValidates an absolute path to ensure it's safe to use
func
cli.src.semgrep.mcp.server.validate_config(config:str | None=None) -> strValidates semgrep configuration parameter
func
cli.src.semgrep.mcp.utilities.tracing.start_tracing(name:str) -> Generator[trace.Span | None, None, None]Initialize OpenTelemetry tracing.
func
cli.src.semgrep.mcp.utilities.utils.findings_elicitation_enabled() -> boolCheck if findings elicitation is enabled.
func
cli.src.semgrep.mcp.utilities.utils.get_anonymous_user_id() -> strReturns the anonymous user ID, if it exists
func
cli.src.semgrep.mcp.utilities.utils.get_deployment_from_jwt() -> dict[str, Any]Returns the deployment data the JWT is for.
func
cli.src.semgrep.mcp.utilities.utils.get_deployment_id() -> int | NoneReturns the deployment ID, if it exists.
func
cli.src.semgrep.mcp.utilities.utils.get_deployment_name() -> str | NoneReturns the deployment name, if it exists.
func
cli.src.semgrep.mcp.utilities.utils.get_identity() -> dict[str, Any]Fetches the identity from Semgrep API.
func
cli.src.semgrep.mcp.utilities.utils.get_semgrep_access_token() -> str | NoneReturns the JWT access token, if it exists.
func
cli.src.semgrep.mcp.utilities.utils.get_semgrep_app_token() -> str | NoneReturns the Semgrep app token, if it exists
func
cli.src.semgrep.mcp.utilities.utils.is_oauth_authenticated() -> boolCheck if the user is authenticated using OAuth.
class
cli.src.semgrep.meta.AzurePipelinesMetaGather metadata from Azure pipelines.
class
cli.src.semgrep.meta.BitbucketMetaGather metadata from BitBucket.
class
cli.src.semgrep.meta.BuildkiteMetaGather metadata from Buildkite.
class
cli.src.semgrep.meta.CircleCIMetaGather metadata from Circle CI.
class
cli.src.semgrep.meta.GitMetaGather metadata only from local filesystem.
method
cli.src.semgrep.meta.GitMeta.commit_datetime() -> strReturns epoch time as str of head commit
class
cli.src.semgrep.meta.GithubMetaGather metadata from GitHub Actions.
class
cli.src.semgrep.meta.GitlabMetaGather metadata from GitLab 10.0+
class
cli.src.semgrep.meta.JenkinsMetaGather metadata from Jenkins CI.
method
cli.src.semgrep.meta.JenkinsMeta.repo_name() -> strConstructs the repo name from the git url.
class
cli.src.semgrep.meta.SemgrepManagedScanMetaGather metadata from Semgrep Managed Scanning.
class
cli.src.semgrep.meta.SemgrepMcpMetaGather metadata from Semgrep MCP.
class
cli.src.semgrep.meta.TravisMetaGather metadata from Travis CI.
func
cli.src.semgrep.meta.get_repo_name_from_repo_url(repo_url:Optional[str]) -> Optional[str]Pulls repository name from the url using a git url parser
func
cli.src.semgrep.meta.get_url_from_sstp_url(sstp_url:Optional[str]) -> Optional[str]Gets regular url from sstp url.
class
cli.src.semgrep.metrics.MetricsTo prevent sending unintended metrics: 1.
method
cli.src.semgrep.metrics.Metrics.add_parse_rates(parse_rates:ParsingData) -> NoneAdds parse rates, grouped by language
method
cli.src.semgrep.metrics.Metrics.add_project_url(project_url:Optional[str]) -> NoneStandardizes url then hashes
method
cli.src.semgrep.metrics.Metrics.is_enabled() -> boolReturns whether metrics should be sent.
method
cli.src.semgrep.metrics.Metrics.send() -> NoneSend metrics to the metrics server.
class
cli.src.semgrep.metrics.MetricsStateConfigures metrics upload.
class
cli.src.semgrep.output.OutputHandlerHandle all output in a central location.
class
cli.src.semgrep.resolve_dependency_source.ResolveDependenciesRpcResultThe result of _resolve_dependencies_rpc
method
cli.src.semgrep.rule.Rule.full_hash() -> strsha256 hash of the whole rule object instead of just the id.
method
cli.src.semgrep.rule.Rule.is_blocking() -> boolReturns if this rule indicates matches should block CI
func
cli.src.semgrep.rule.rule_without_metadata(rule:Rule) -> RuleKey used to deduplicate rules.
func
cli.src.semgrep.rule_lang.build_rule_spans(yaml_tree:YamlTree) -> Dict[str, Span]Extract rule_id -> YAML Span from a parsed YamlTree.
func
cli.src.semgrep.rule_lang.parse_yaml_preserve_spans(contents:str, filename:Optional[str], allow_null:bool=False) -> Optional[YamlTree]parse yaml into a YamlTree object.
func
cli.src.semgrep.rule_lang.run_rpc_validate_exn(rules_tmp_path:str) -> NoneApplies validation to a file at rules_tmp_path via semgrep-core.
func
cli.src.semgrep.rule_lang.sanitize_rule_id_fragment(s:str) -> strMake a valid fragment for a rule ID.
method
cli.src.semgrep.rule_match.RuleMatch.get_ordering_key() -> Tuple[str, Position, Position, str, str]Used to sort findings in output.
method
cli.src.semgrep.rule_match.RuleMatch.get_path_changed_ci_unique_key(rename_dict:Dict[str, Path]) -> Tuple[str, str, str, int]A unique key that accounts for filepath renames.
method
cli.src.semgrep.rule_match.RuleMatch.get_previous_line() -> strReturn the line preceding the match, if any.
method
cli.src.semgrep.rule_match.RuleMatch.get_syntactic_id() -> strA 32-character hash representation of ci_unique_key.
method
cli.src.semgrep.rule_match.RuleMatch.is_blocking() -> boolReturns if this finding indicates it should block CI
method
cli.src.semgrep.rule_match.RuleMatch.to_app_finding_format(commit_date:str, remove_dataflow_content:bool) -> out.Findingcommit_date here for legacy reasons.
func
cli.src.semgrep.safe_set.intersection(a:FrozenSet[T], b:Collection[T]) -> FrozenSet[T]Intersect two sets containing elements of the same type.
func
cli.src.semgrep.safe_set.union(a:FrozenSet[T], b:Collection[T]) -> FrozenSet[T]Take the union of two sets containing elements of the same type.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.AnalysisTypeOriginal type: analysis_type = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.AnalysisType.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Any_Original type: secrets_origin = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Any_.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.CodeConfigOriginal type: code_config = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.DatetimeOriginal type: datetime
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.EngineConfigOriginal type: engine_config = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.EnvironmentOriginal type: environment = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ErrorOriginal type: error
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ErrorsOriginal type: errors = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ExtensionOriginal type: extension = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.FileStatsOriginal type: file_stats = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.FindingOriginal type: finding = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.GuardianOriginal type: guardian = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.InstallProOriginal type: install_pro = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.InterfileOriginal type: analysis_type = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Interfile.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.InterproceduralOriginal type: analysis_type = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Interprocedural.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.IntraproceduralOriginal type: analysis_type = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Intraprocedural.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.LangOriginal type: lang
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.McpOriginal type: mcp = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.NoCommunityOriginal type: secrets_origin = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.NoCommunity.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ParseStatOriginal type: parse_stat = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.PayloadOriginal type: payload = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.PerformanceOriginal type: performance = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ProFeaturesOriginal type: pro_features = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.RuleStatsOriginal type: rule_stats = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.SecretsConfigOriginal type: secrets_config = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.SecretsOriginOriginal type: secrets_origin = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.SecretsOrigin.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.SemgrepOriginal type: secrets_origin = [ ...
method
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Semgrep.kind() -> strName of the class representing this variant.
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.Sha256Original type: sha256
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.SupplyChainConfigOriginal type: supply_chain_config = { ...
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.UuidOriginal type: uuid
class
cli.src.semgrep.semgrep_interfaces.semgrep_metrics.ValueOriginal type: value = { ...
method
cli.src.semgrep.settings.Settings.delete(key:SettingsKeys) -> NoneDeletes key KEY from settings file if it exists Noop otherwise
method
cli.src.semgrep.settings.Settings.get_default_contents() -> SettingsSchemaIf file exists, read file.
class
cli.src.semgrep.simple_profiling.ProfilingEntryMutable accumulator for execution time
func
cli.src.semgrep.simple_profiling.export_simple_profiling() -> list[out.ProfilingEntry]Produce a list sorted by decreasing total_time
func
cli.src.semgrep.simple_profiling.import_simple_profiling(entries:list[out.ProfilingEntry]) -> NoneImport profiling data from semgrep-core
func
cli.src.semgrep.state.get_context() -> click.ContextGet the current CLI invocation's click context.
func
cli.src.semgrep.state.get_state() -> SemgrepStateGet the current CLI invocation's global state.
func
cli.src.semgrep.subproject.count_resolved_dependencies(d:Dict[out.DependencyChild, List[out.ResolvedDependency]]) -> intCount the number of dependencies
func
cli.src.semgrep.subproject.subproject_sort_key(subproject:Union[out.ResolvedSubproject, out.UnresolvedSubproject]) -> Tuple[Tuple[int, int], str]Used to sort subprojects in the table.
func
cli.src.semgrep.subproject.subproject_to_stats(sub:Union[out.ResolvedSubproject, out.UnresolvedSubproject]) -> out.SubprojectStatsConvert a subproject to subproject stats.
class
cli.src.semgrep.target_manager.FileTargetingLogKeeps track of which paths were ignored for what reason.
class
cli.src.semgrep.target_manager.ScanningRootRepresents one path that was given as a scanning root.
method
cli.src.semgrep.target_manager.ScanningRoot.files_from_git_diff() -> FrozenSet[Path]Get only changed files since baseline commit.
method
cli.src.semgrep.target_manager.ScanningRoot.validate_path(_:Any, value:Path) -> NoneCheck whether the targeted path exists.
class
cli.src.semgrep.terminal.TerminalFundamental settings on how to log output.
class
cli.src.semgrep.types.FilteredFilesThe return value of functions that filters target files.
class
cli.src.semgrep.types.FilteredMatchesThe return value of functions that filter matches files.
class
cli.src.semgrep.types.SelectedTargetsImmutable container for selected targets that were obtained.
class
cli.src.semgrep.types.TargetAccumulatorAccumulate targets that are scanned by Semgrep rules.
func
cli.src.semgrep.types.fake_target_of_path(path:Path) -> TargetFor tests only!
func
cli.src.semgrep.types.fake_targets_of_paths(paths:Iterable[Path]) -> FrozenSet[Target]For tests only!
func
cli.src.semgrep.util.get_lines_from_file(path:Path, start_line:int, end_line:int) -> List[str]Return lines in the given file.
func
cli.src.semgrep.util.get_lines_from_git_blob(blob_sha:Sha1, start_line:int, end_line:int) -> List[str]Return lines in the given git blob.
func
cli.src.semgrep.util.has_color() -> boolDetermine if color should be used in the output.
func
cli.src.semgrep.util.is_secrets_ai_ruleset(metadata:Mapping[str, Any]) -> boolCheck if a rule or match is from the semgrep-secrets-ai ruleset.
func
cli.src.semgrep.util.is_truthy(value:Any) -> boolReturns True if the value is a truthy value, False otherwise.
func
cli.src.semgrep.util.json_win_paths_to_posix(json:Any) -> AnyConvert all Windows relative paths in a JSON object to POSIX paths.
func
cli.src.semgrep.util.listendswith(l:List[T], tail:List[T]) -> boolE.g.
func
cli.src.semgrep.util.redact_credentials(s:str) -> strStrip URL userinfo and Authorization-header values from [s].
func
cli.src.semgrep.util.welcome() -> NonePrint a welcome message with the Semgrep logo.
func
cli.src.semgrep.util.with_logo_color(text:str) -> strWrap text with our brand color if color is enabled.
class
perf.config.BenchmarkRunSetupDataStores data about an individual benchmark run
class
perf.config.SemgrepBenchmarkConfigStores data needed to start a benchmarking run.
この情報について
掲載しているシグネチャは semgrep/semgrep の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。