MCPcopy
hub / github.com/slimtoolkit/slim / inspectFile

Function inspectFile

pkg/docker/dockerimage/dockerimage.go:1713–2115  ·  view source on GitHub ↗
(
	object *ObjectMetadata,
	reader io.Reader,
	pkg *Package,
	layer *Layer,
	doHashData bool,
	changeDataHashMatchers map[string]*ChangeDataHashMatcher,
	changePathMatchers []*ChangePathMatcher,
	cpmDumps bool,
	changeDataMatchers map[string]*ChangeDataMatcher,
	utf8Detector *UTF8Detector,
	processorParams *ProcessorParams,
)

Source from the content-addressed store, hash-verified

1711func (f *utf8FileInfo) Sys() interface{} { return nil }
1712
1713func inspectFile(
1714 object *ObjectMetadata,
1715 reader io.Reader,
1716 pkg *Package,
1717 layer *Layer,
1718 doHashData bool,
1719 changeDataHashMatchers map[string]*ChangeDataHashMatcher,
1720 changePathMatchers []*ChangePathMatcher,
1721 cpmDumps bool,
1722 changeDataMatchers map[string]*ChangeDataMatcher,
1723 utf8Detector *UTF8Detector,
1724 processorParams *ProcessorParams,
1725) error {
1726 //TODO: refactor and enhance the OS Distro detection logic
1727 fullPath := object.Name
1728
1729 var cdhmDumps bool
1730 for _, dhm := range changeDataHashMatchers {
1731 if dhm.Dump {
1732 cdhmDumps = true
1733 break
1734 }
1735 }
1736
1737 var isKnownCertFile bool
1738 if certdiscover.IsCertFile(fullPath) {
1739 pkg.Certs.Bundles[fullPath] = struct{}{}
1740 isKnownCertFile = true
1741 } else if certdiscover.IsAppCertFile(fullPath) {
1742 pkg.Certs.Bundles[fullPath] = struct{}{}
1743 isKnownCertFile = true
1744 } else if certdiscover.IsCACertFile(fullPath) {
1745 pkg.CACerts.Bundles[fullPath] = struct{}{}
1746 isKnownCertFile = true
1747 } else if certdiscover.IsCACertPKFile(fullPath) {
1748 pkg.CACerts.PrivateKeys[fullPath] = struct{}{}
1749 isKnownCertFile = true
1750 }
1751
1752 if (processorParams.DetectIdentities.Enabled &&
1753 sysidentity.IsSourceFile(fullPath)) ||
1754 system.IsOSReleaseFile(fullPath) ||
1755 system.IsOSShellsFile(fullPath) ||
1756 len(changeDataMatchers) > 0 ||
1757 cpmDumps ||
1758 cdhmDumps ||
1759 utf8Detector != nil ||
1760 (!isKnownCertFile && processorParams.DetectAllCertFiles) ||
1761 (!isKnownCertFile && processorParams.DetectAllCertPKFiles) {
1762 data, err := io.ReadAll(reader)
1763 if err != nil {
1764 return err
1765 }
1766
1767 if processorParams.DetectIdentities.Enabled &&
1768 sysidentity.IsSourceFile(fullPath) {
1769 pkg.IdentityData.AddData(fullPath, data)
1770 }

Callers 1

layerFromStreamFunction · 0.85

Calls 15

IsCertFileFunction · 0.92
IsAppCertFileFunction · 0.92
IsCACertFileFunction · 0.92
IsCACertPKFileFunction · 0.92
IsSourceFileFunction · 0.92
IsOSReleaseFileFunction · 0.92
IsOSShellsFileFunction · 0.92
IsCertDataFunction · 0.92
IsCACertDirPathFunction · 0.92
IsPrivateKeyDataFunction · 0.92
IsCACertPKDirPathFunction · 0.92
NewOSShellsFromDataFunction · 0.92

Tested by

no test coverage detected