mirror of
https://github.com/slimtoolkit/slim.git
synced 2025-06-03 04:00:23 +00:00
shell detection enhancements for xray
This commit is contained in:
parent
10c72982ce
commit
5ac34b5581
@ -877,6 +877,16 @@ func printImagePackage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, info := range pkg.OSShells {
|
for _, info := range pkg.OSShells {
|
||||||
|
xc.Out.Info("image.shells",
|
||||||
|
ovars{
|
||||||
|
"full_name": info.FullName,
|
||||||
|
"short_name": info.ShortName,
|
||||||
|
"exe_path": info.ExePath,
|
||||||
|
"link_path": info.LinkPath,
|
||||||
|
"reference": info.Reference,
|
||||||
|
"verified": info.Verified,
|
||||||
|
})
|
||||||
|
|
||||||
cmdReport.ImageReport.OSShells = append(cmdReport.ImageReport.OSShells, info)
|
cmdReport.ImageReport.OSShells = append(cmdReport.ImageReport.OSShells, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,6 +599,18 @@ func LoadPackage(archivePath string,
|
|||||||
case ChangeDelete:
|
case ChangeDelete:
|
||||||
object.History.Delete = &changeInfo
|
object.History.Delete = &changeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if object.Change == ChangeAdd ||
|
||||||
|
object.Change == ChangeModify {
|
||||||
|
if shellInfo, found := pkg.OSShells[object.Name]; found {
|
||||||
|
if exeInfo, rfound := layer.References[shellInfo.ExePath]; rfound {
|
||||||
|
shellInfo.Verified = true
|
||||||
|
if exeInfo.LinkTarget != "" {
|
||||||
|
shellInfo.LinkPath = exeInfo.LinkTarget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if utf8Detector != nil {
|
if utf8Detector != nil {
|
||||||
@ -696,6 +708,18 @@ func LoadPackage(archivePath string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if object.Change == ChangeAdd ||
|
||||||
|
object.Change == ChangeModify {
|
||||||
|
if shellInfo, found := pkg.OSShells[object.Name]; found {
|
||||||
|
if exeInfo, rfound := layer.References[shellInfo.ExePath]; rfound {
|
||||||
|
shellInfo.Verified = true
|
||||||
|
if exeInfo.LinkTarget != "" {
|
||||||
|
shellInfo.LinkPath = exeInfo.LinkTarget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if utf8Detector != nil {
|
if utf8Detector != nil {
|
||||||
layer.Stats.UTF8SizeHuman = humanize.Bytes(layer.Stats.UTF8Size)
|
layer.Stats.UTF8SizeHuman = humanize.Bytes(layer.Stats.UTF8Size)
|
||||||
@ -884,12 +908,6 @@ func layerFromStream(
|
|||||||
if isDeleted {
|
if isDeleted {
|
||||||
layer.Stats.DeletedLinkCount++
|
layer.Stats.DeletedLinkCount++
|
||||||
pkg.Stats.DeletedLinkCount++
|
pkg.Stats.DeletedLinkCount++
|
||||||
} else {
|
|
||||||
if shellInfo, found := pkg.OSShells[object.Name]; found {
|
|
||||||
if shellInfo.ExePath == object.Name {
|
|
||||||
shellInfo.LinkPath = object.LinkTarget
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case tar.TypeReg:
|
case tar.TypeReg:
|
||||||
layer.Stats.FileCount++
|
layer.Stats.FileCount++
|
||||||
@ -916,13 +934,6 @@ func layerFromStream(
|
|||||||
pkg.Stats.StickyCount++
|
pkg.Stats.StickyCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
if shellInfo, found := pkg.OSShells[object.Name]; found {
|
|
||||||
if shellInfo.ExePath == object.Name {
|
|
||||||
//not ideal, need to verify Reference and LinkPath too
|
|
||||||
shellInfo.Verified = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = inspectFile(
|
err = inspectFile(
|
||||||
object,
|
object,
|
||||||
tr,
|
tr,
|
||||||
|
Loading…
Reference in New Issue
Block a user