mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 00:48:10 +01:00
chore(aa-log): make some resource internal only.
This commit is contained in:
parent
fe2edb31d8
commit
26bd9350f2
2 changed files with 31 additions and 31 deletions
|
@ -20,6 +20,11 @@ var LogFiles = []string{
|
||||||
"/var/log/syslog",
|
"/var/log/syslog",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SystemdLog is a simplified systemd json log representation.
|
||||||
|
type systemdLog struct {
|
||||||
|
Message string `json:"MESSAGE"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetAuditLogs return a reader with the logs entries from Auditd
|
// GetAuditLogs return a reader with the logs entries from Auditd
|
||||||
func GetAuditLogs(path string) (io.Reader, error) {
|
func GetAuditLogs(path string) (io.Reader, error) {
|
||||||
file, err := os.Open(filepath.Clean(path))
|
file, err := os.Open(filepath.Clean(path))
|
||||||
|
@ -31,7 +36,7 @@ func GetAuditLogs(path string) (io.Reader, error) {
|
||||||
|
|
||||||
// GetJournalctlLogs return a reader with the logs entries from Systemd
|
// GetJournalctlLogs return a reader with the logs entries from Systemd
|
||||||
func GetJournalctlLogs(path string, useFile bool) (io.Reader, error) {
|
func GetJournalctlLogs(path string, useFile bool) (io.Reader, error) {
|
||||||
var logs []SystemdLog
|
var logs []systemdLog
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
var value string
|
var value string
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,16 @@ import (
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
const (
|
const (
|
||||||
Reset = "\033[0m"
|
reset = "\033[0m"
|
||||||
FgGreen = "\033[32m"
|
fgGreen = "\033[32m"
|
||||||
FgYellow = "\033[33m"
|
fgYellow = "\033[33m"
|
||||||
FgBlue = "\033[34m"
|
fgBlue = "\033[34m"
|
||||||
FgMagenta = "\033[35m"
|
fgMagenta = "\033[35m"
|
||||||
FgCian = "\033[36m"
|
fgCian = "\033[36m"
|
||||||
FgWhite = "\033[37m"
|
fgWhite = "\033[37m"
|
||||||
BoldRed = "\033[1;31m"
|
boldRed = "\033[1;31m"
|
||||||
BoldGreen = "\033[1;32m"
|
boldGreen = "\033[1;32m"
|
||||||
BoldYellow = "\033[1;33m"
|
boldYellow = "\033[1;33m"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -47,11 +47,6 @@ type AppArmorLog map[string]string
|
||||||
// AppArmorLogs describes all apparmor log entries
|
// AppArmorLogs describes all apparmor log entries
|
||||||
type AppArmorLogs []AppArmorLog
|
type AppArmorLogs []AppArmorLog
|
||||||
|
|
||||||
// SystemdLog is a simplified systemd json log representation.
|
|
||||||
type SystemdLog struct {
|
|
||||||
Message string `json:"MESSAGE"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func splitQuoted(r rune) bool {
|
func splitQuoted(r rune) bool {
|
||||||
if r == '"' {
|
if r == '"' {
|
||||||
quoted = !quoted
|
quoted = !quoted
|
||||||
|
@ -125,9 +120,9 @@ func NewApparmorLogs(file io.Reader, profile string) AppArmorLogs {
|
||||||
func (aaLogs AppArmorLogs) String() string {
|
func (aaLogs AppArmorLogs) String() string {
|
||||||
// Apparmor log states
|
// Apparmor log states
|
||||||
state := map[string]string{
|
state := map[string]string{
|
||||||
"DENIED": BoldRed + "DENIED " + Reset,
|
"DENIED": boldRed + "DENIED " + reset,
|
||||||
"ALLOWED": BoldGreen + "ALLOWED" + Reset,
|
"ALLOWED": boldGreen + "ALLOWED" + reset,
|
||||||
"AUDIT": BoldYellow + "AUDIT " + Reset,
|
"AUDIT": boldYellow + "AUDIT " + reset,
|
||||||
}
|
}
|
||||||
// Print order of impression
|
// Print order of impression
|
||||||
keys := []string{
|
keys := []string{
|
||||||
|
@ -140,17 +135,17 @@ func (aaLogs AppArmorLogs) String() string {
|
||||||
}
|
}
|
||||||
// Color template to use
|
// Color template to use
|
||||||
colors := map[string]string{
|
colors := map[string]string{
|
||||||
"profile": FgBlue,
|
"profile": fgBlue,
|
||||||
"label": FgBlue,
|
"label": fgBlue,
|
||||||
"operation": FgYellow,
|
"operation": fgYellow,
|
||||||
"name": FgMagenta,
|
"name": fgMagenta,
|
||||||
"mask": BoldRed,
|
"mask": boldRed,
|
||||||
"bus": FgCian + "bus=",
|
"bus": fgCian + "bus=",
|
||||||
"path": "path=" + FgWhite,
|
"path": "path=" + fgWhite,
|
||||||
"requested_mask": "requested_mask=" + BoldRed,
|
"requested_mask": "requested_mask=" + boldRed,
|
||||||
"denied_mask": "denied_mask=" + BoldRed,
|
"denied_mask": "denied_mask=" + boldRed,
|
||||||
"interface": "interface=" + FgWhite,
|
"interface": "interface=" + fgWhite,
|
||||||
"member": "member=" + FgGreen,
|
"member": "member=" + fgGreen,
|
||||||
}
|
}
|
||||||
res := ""
|
res := ""
|
||||||
for _, log := range aaLogs {
|
for _, log := range aaLogs {
|
||||||
|
@ -160,7 +155,7 @@ func (aaLogs AppArmorLogs) String() string {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if log[key] != "" {
|
if log[key] != "" {
|
||||||
if colors[key] != "" {
|
if colors[key] != "" {
|
||||||
res += " " + colors[key] + toQuote(log[key]) + Reset
|
res += " " + colors[key] + toQuote(log[key]) + reset
|
||||||
} else {
|
} else {
|
||||||
res += " " + key + "=" + toQuote(log[key])
|
res += " " + key + "=" + toQuote(log[key])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue