Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Add new ALF plist location for macOS 15 #5013

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion providers/os/resources/macos_alf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,44 @@
package resources

import (
"errors"

"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/llx"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/os/connection/shared"
"go.mondoo.com/cnquery/v11/types"
)

var alfPlistLocations = []string{
"/Library/Preferences/com.apple.alf.plist",
"/usr/libexec/ApplicationFirewall/com.apple.alf.plist",
}

func initMacosAlf(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) {
conn := runtime.Connection.(shared.Connection)

if args == nil {
args = map[string]*llx.RawData{}
}

f, err := conn.FileSystem().Open("/Library/Preferences/com.apple.alf.plist")
var plistLocation string
fs := conn.FileSystem()
for _, loc := range alfPlistLocations {
log.Debug().Str("location", loc).Msg("Checking for ALF configuration")
s, err := fs.Stat(loc)
if err == nil && !s.IsDir() {
log.Debug().Str("location", loc).Msg("Found ALF configuration")
plistLocation = loc
break
}
}

if plistLocation == "" {
return nil, nil, errors.New("ALF configuration not found")
}

f, err := fs.Open(plistLocation)
if err != nil {
return nil, nil, err
}
Expand Down
Loading