Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-swanson committed Dec 15, 2021
1 parent c95a65a commit 4ac59de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions winlogbeat/eventlog/wineventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func (c *winEventLogConfig) Validate() error {
errs = append(errs, fmt.Errorf("event log is missing an 'id'"))
}

var tmp interface{}
if err := xml.Unmarshal([]byte(c.XMLQuery), &tmp); err != nil {
// Check for XML syntax errors. This does not check the validity of the query itself.
if err := xml.Unmarshal([]byte(c.XMLQuery), &struct{}{}); err != nil {
errs = append(errs, fmt.Errorf("invalid xml_query: %w", err))
}

Expand All @@ -137,10 +137,8 @@ func (c *winEventLogConfig) Validate() error {
case len(c.SimpleQuery.Provider) != 0:
errs = append(errs, fmt.Errorf("xml_query cannot be used with 'provider'"))
}
} else {
if c.Name == "" {
errs = append(errs, fmt.Errorf("event log is missing a 'name'"))
}
} else if c.Name == "" {
errs = append(errs, fmt.Errorf("event log is missing a 'name'"))
}

return errs.Err()
Expand Down Expand Up @@ -410,12 +408,13 @@ func newWinEventLog(options *common.Config) (EventLog, error) {
}

id := c.ID
if id == "" {
id = c.Name
}

if c.XMLQuery != "" {
xmlQuery = c.XMLQuery
} else {
if id == "" {
id = c.Name
}
xmlQuery, err = win.Query{
Log: c.Name,
IgnoreOlder: c.SimpleQuery.IgnoreOlder,
Expand Down
8 changes: 4 additions & 4 deletions winlogbeat/eventlog/wineventlog_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ func newWinEventLogExp(options *common.Config) (EventLog, error) {
}

id := c.ID
if id == "" {
id = c.Name
}

if c.XMLQuery != "" {
xmlQuery = c.XMLQuery
log = logp.NewLogger("wineventlog").With("id", id)
} else {
if id == "" {
id = c.Name
}

queryLog := c.Name
if info, err := os.Stat(c.Name); err == nil && info.Mode().IsRegular() {
path, err := filepath.Abs(c.Name)
Expand Down

0 comments on commit 4ac59de

Please sign in to comment.