{"modulePath":"github.com/jfrog/jfrog-cli-security","version":"v1.41.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package techutils\n\n## Constants\n\n```go\nconst Gav = \"gav\" // maven, gradle\n\n```\n\n```go\nconst JfrogCleanTechSubModulesEnv = \"JFROG_CLI_CLEAN_SUB_MODULES\"\n```\n\n```go\nconst Pypi = \"pypi\" // pip, pipenv, poetry\n\n```\nAlternative package types for some technologies\n\n## Variables\n\n```go\nvar AllTechnologiesStrings = []string{\n\tMaven.String(),\n\tGradle.String(),\n\tNpm.String(),\n\tPnpm.String(),\n\tYarn.String(),\n\tGo.String(),\n\tPip.String(),\n\tPipenv.String(),\n\tPoetry.String(),\n\tUv.String(),\n\tNuget.String(),\n\tDotnet.String(),\n\tDocker.String(),\n\tHuggingFaceML.String(),\n\tOci.String(),\n\tConan.String(),\n\tCocoapods.String(),\n\tSwift.String(),\n\tNoTech.String(),\n\tGem.String(),\n\tCargo.String(),\n\tRpm.String(),\n\tDebian.String(),\n\tComposer.String(),\n\tAlpine.String(),\n}\n```\n\n## Functions\n\n```go\nfunc CdxPackageTypeToXrayPackageType(cdxPackageType string) string\n```\n\n```go\nfunc ComponentPackageTypeToXrayType(packageType string) string\n```\nComponentPackageTypeToXrayType normalizes a CDX PURL type or Xray component-id type to an Xray package type.\n\n```go\nfunc DecodeYarnWorkspacesField(raw json.RawMessage) []string\n```\nDecodeYarnWorkspacesField accepts either form yarn V2+ allows in package.json — the array form (\\[\"packages/\\*\"]) or the object form ({\"packages\": \\[...]}) — and returns the flat list of glob patterns. Anything else (bare string, number, etc.) is rejected and returns nil so the caller treats the ancestor as not claiming the target. Shared between curation detection here and the yarn package's workspace-root walk to keep the two semantics in sync.\n\n```go\nfunc DetectTechnologiesDescriptors(path string, recursive bool, requestedTechs []string, requestedDescriptors map[Technology][]string, excludePathPattern string) (technologiesDetected map[Technology]map[string][]string, err error)\n```\nIf recursive is true, the search will not be limited to files in the root path. If recursive is true the search may return Technology.NoTech value If requestedTechs is empty, all technologies will be checked. If excludePathPattern is not empty, files/directories that match the wildcard pattern will be excluded from the search.\n\n```go\nfunc DetectedTechnologiesList() (technologies []string)\n```\n\n```go\nfunc DetectedTechnologiesListForCurationAudit() (technologies []string)\n```\nDetectedTechnologiesListForCurationAudit is DetectedTechnologiesListForCurationAuditWithRequirementsFile with no requirements file.\n\n```go\nfunc DetectedTechnologiesListForCurationAuditWithRequirementsFile(pipRequirementsFile string) (technologies []string)\n```\nDetectedTechnologiesListForCurationAuditWithRequirementsFile is the curation-audit variant of DetectedTechnologiesList that additionally re-routes any working directory detected as Npm to Yarn whenever a parent directory is a yarn workspace root that claims it. The promotion is curation-only by design — the generic file-based detector intentionally does not walk upward, and other commands ('jf audit', 'jf scan', etc.) keep the legacy npm-fallback behaviour for yarn workspace members so this change cannot regress them.\n\npipRequirementsFile is the --requirements-file value; it is matched as jf audit matches it.\n\nUnlike DetectedTechnologiesList, this does not log the result: the caller still has more promotions to apply (pnpm/yarn, pip→uv) before the list is final, and logging early could show a technology immediately superseded (e.g. \"Detected: pip.\" right before \"...treating as uv.\").\n\nUsed by techsToAudit so 'jf ca --working-dirs=\\\u003cworkspace member\u003e' resolves through yarn (matching how the project's lockfile was produced) instead of npm (which would synthesise a different dependency set and produce curation answers that don't match what yarn would have resolved).\n\n```go\nfunc DetectedTechnologiesToSlice(detected map[Technology]map[string][]string) []string\n```\nDetectedTechnologiesToSlice returns a string slice that includes all the names of the detected technologies.\n\n```go\nfunc DirectoryHasYarnIndicator(dir string) bool\n```\nDirectoryHasYarnIndicator reports whether dir carries any of the files that mark it as a yarn-managed project root. Used to disambiguate between yarn and npm workspaces — both ecosystems share the \"workspaces\" field in package.json, but only yarn puts these indicators next to it. Shared by curation detection here and by yarn's workspace-root walk in sca/bom/buildinfo/technologies/yarn.\n\n```go\nfunc HasPep723ScriptMetadata(content string) bool\n```\nHasPep723ScriptMetadata reports whether content contains a PEP 723 inline script metadata block: a \"# /// script\" line followed later by a lone \"# ///\" closing line.\n\n```go\nfunc IsAmbiguousTechnologyString(technology string) bool\n```\nIsAmbiguousTechnologyString returns true for Xray/CDX types that map to multiple package managers (pypi, gav, npm, etc.).\n\n```go\nfunc IsLockFilePackageDescriptor(path string) bool\n```\n\n```go\nfunc IsValidTechnology(tech string) bool\n```\n\n```go\nfunc Pep723ScriptUnauditedHint(wd string) string\n```\nPep723ScriptUnauditedHint returns a hint when wd contains a PEP 723 script (or \"\" if none), since jf ca only audits one via --script.\n\nCallers must only invoke this once uv was confirmed detected in wd, and must log the result themselves — this function never logs directly, since jf ca's progress spinner would swallow a log line emitted while it's active.\n\n```go\nfunc PurlToXrayComponentId(purl string) (xrayComponentId string)\n```\nExtract the component name, version and type from PackageUrl and translate it to an Xray component id\n\n```go\nfunc SplitComponentId(componentId string) (string, string, string)\n```\n\n```go\nfunc SplitComponentIdRaw(componentId string) (string, string, string)\n```\nSplitComponentIdRaw splits a Xray component ID to the component name, version and package type. In case componentId doesn't contain a version, the returned version will be an empty string. In case componentId's format is invalid, it will be returned as the component name and empty strings will be returned instead of the version and the package type. Examples:\n\n 1. componentId: \"gav://antparent:ant:1.6.5\" Returned values: Component name: \"antparent:ant\" Component version: \"1.6.5\" Package type: \"gav\"\n 2. componentId: \"generic://sha256:244fd47e07d1004f0aed9c156aa09083c82bf8944eceb67c946ff7430510a77b/foo.jar\" Returned values: Component name: \"foo.jar\" Component version: \"\" Package type: \"generic\"\n 3. componentId: \"invalid-comp-id\" Returned values: Component name: \"invalid-comp-id\" Component version: \"\" Package type: \"\"\n\n```go\nfunc SplitPackageURL(purl string) (compName, compVersion, packageType string)\n```\n\n```go\nfunc SplitPackageUrlWithQualifiers(purl string) (packageType, compNamespace, compName, compVersion string, qualifiers map[string]string)\n```\n[https://github.com/package-url/purl-spec/blob/main/PURL-SPECIFICATION.rst](https://github.com/package-url/purl-spec/blob/main/PURL-SPECIFICATION.rst) Parse a given Package URL (purl) and return the component namespace, name, version, and package type.\n\n```go\nfunc ToFormalString(technologies []Technology) string\n```\n\n```go\nfunc ToPackageRef(compName, version, packageType string) (output string)\n```\n\n```go\nfunc ToPackageUrl(compName, version, packageType string, properties ...packageurl.Qualifier) (output string)\n```\nscheme:type/namespace/name@version?qualifiers#subpath -\u003e pkg:type/namespace/name@version?properties\n\n```go\nfunc ToXrayComponentId(packageType, componentName, componentVersion string) string\n```\n\n```go\nfunc XrayComponentIdToCdxComponentRef(xrayImpactedPackageId string) string\n```\n\n```go\nfunc XrayComponentIdToPurl(xrayComponentId string) (purl string)\n```\n\n```go\nfunc XrayPackageTypeToCdxPackageType(xrayPackageType string) string\n```\n\n## Types\n\n```go\ntype CodeLanguage string\n```\n\n```go\nconst (\n\tJavaScript CodeLanguage = \"javascript\"\n\tPython     CodeLanguage = \"python\"\n\tGoLang     CodeLanguage = \"go\"\n\tJava       CodeLanguage = \"java\"\n\tCSharp     CodeLanguage = \"C#\"\n\tCPP        CodeLanguage = \"C++\"\n\tRuby       CodeLanguage = \"ruby\"\n\tRust       CodeLanguage = \"rust\"\n\t// package can have multiple languages\n\tCocoapodsLang CodeLanguage = \"Any\"\n\tSwiftLang     CodeLanguage = \"Any\"\n)\n```\n\n```go\ntype ContentValidator func(content []byte) bool\n```\nGiven a file content, returns true if the content is an indicator of the technology.\n\n```go\ntype TechData struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype Technology string\n```\n\n```go\nconst (\n\tMaven     Technology = \"maven\"\n\tGradle    Technology = \"gradle\"\n\tNpm       Technology = \"npm\"\n\tPnpm      Technology = \"pnpm\"\n\tYarn      Technology = \"yarn\"\n\tGo        Technology = \"go\"\n\tPip       Technology = \"pip\"\n\tPipenv    Technology = \"pipenv\"\n\tPoetry    Technology = \"poetry\"\n\tUv        Technology = \"uv\"\n\tNuget     Technology = \"nuget\"\n\tDotnet    Technology = \"dotnet\"\n\tConan     Technology = \"conan\"\n\tCocoapods Technology = \"cocoapods\"\n\tSwift     Technology = \"swift\"\n\tGem       Technology = \"ruby\"\n\tCargo     Technology = \"cargo\"\n\t// Not Supported by build-info BOM generator\n\tDocker        Technology = \"docker\"\n\tHuggingFaceML Technology = \"huggingfaceml\"\n\tOci           Technology = \"oci\"\n\tRpm           Technology = \"rpm\"\n\tDebian        Technology = \"deb\"\n\tComposer      Technology = \"composer\"\n\tAlpine        Technology = \"alpine\"\n\tCpp           Technology = \"cpp\"\n\tNoTech        Technology = \"\"\n)\n```\n\n```go\nfunc CdxPackageTypeToTechnology(cdxPackageType string) Technology\n```\n\n```go\nfunc GetAllTechnologiesList() (technologies []Technology)\n```\n\n```go\nfunc IsTechnologyDescriptor(path string) Technology\n```\n\n```go\nfunc PromotePipToUv(techs []Technology, dir string) []Technology\n```\nPromotePipToUv resolves the ambiguity between Pip and Uv for a single working directory: Pip's generic \"pyproject.toml\" indicator also matches a uv-managed project, since a uv pyproject.toml carries neither a \\[tool.poetry] section nor a hatch/flit/pdm build-backend. Rule, in order:\n\n 1. Pip-exclusive file present (requirements.txt, setup.py, setup.cfg, Pipfile, poetry.lock) → Pip wins, Uv is dropped.\n 2. Otherwise, a project-local uv signal (uv.lock or a pyproject.toml \\[tool.uv] / \\[\\[tool.uv.\\*]] table) → Uv wins, Pip is dropped.\n\n~/.config/uv/uv.toml (machine-global) is not checked here; 'jf curation-audit' uses PromotePipToUvForCurationAudit instead, which also honors it.\n\ndir is the working directory being evaluated - callers must pass it explicitly rather than relying on the process's current directory, since a single process may evaluate several targets without changing it.\n\n```go\nfunc PromotePipToUvForCurationAudit(techs []Technology, dir string) []Technology\n```\nPromotePipToUvForCurationAudit is PromotePipToUv, plus: a machine-global ~/.config/uv/uv.toml also counts as a uv signal, for 'jf curation-audit' only.\n\n```go\nfunc ResolveIssueTechnology(responseTechnology string, targetTechnologies []Technology, componentPackageType string) Technology\n```\nResolveIssueTechnology picks the most specific technology for an SCA issue using the Xray response, detected target technologies, and the impacted component package type.\n\n```go\nfunc TechnologiesInTargetsWithXrayType(targets []Technology, xrayType string) []Technology\n```\nTechnologiesInTargetsWithXrayType returns target technologies that share the given Xray package type ecosystem.\n\n```go\nfunc ToTechnologies(args []string) (technologies []Technology)\n```\n\n```go\nfunc ToTechnology(tech string) Technology\n```\n\n```go\nfunc (tech Technology) GetExecCommandName() string\n```\n\n```go\nfunc (tech Technology) GetLanguage() CodeLanguage\n```\n\n```go\nfunc (tech Technology) GetPackageDescriptor() []string\n```\n\n```go\nfunc (tech Technology) GetPackageInstallationCommand() string\n```\n\n```go\nfunc (tech Technology) GetPackageType() string\n```\n\n```go\nfunc (tech Technology) GetPackageVersionOperator() string\n```\n\n```go\nfunc (tech Technology) GetProjectType() project.ProjectType\n```\n\n```go\nfunc (tech Technology) GetXrayPackageType() string\n```\n\n```go\nfunc (tech Technology) GetXrayPackageTypeId() string\n```\n\n```go\nfunc (tech Technology) String() string\n```\n\n```go\nfunc (tech Technology) ToFormal() string\n```\n\n","path":"github.com/jfrog/jfrog-cli-security/utils/techutils","name":"techutils","synopsis":"","isRedistributable":true}
