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

[Winlogbeat] Move winlogbeat javascript processor to libbeat #21402

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions libbeat/processors/script/javascript/module/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ import (
_ "github.com/elastic/beats/v7/libbeat/processors/script/javascript/module/path"
_ "github.com/elastic/beats/v7/libbeat/processors/script/javascript/module/processor"
_ "github.com/elastic/beats/v7/libbeat/processors/script/javascript/module/require"
_ "github.com/elastic/beats/v7/libbeat/processors/script/javascript/module/windows"
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
// Package winlogbeat registers the winlogbeat module with the javascript script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Package winlogbeat registers the winlogbeat module with the javascript script
// Package windows registers the windows module with the javascript script

// processor. The module has utilities specific to Winlogbeat like parsing
// Windows command lines.
package winlogbeat
package windows
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// +build windows

package winlogbeat
package windows

import (
"syscall"
Expand Down Expand Up @@ -74,9 +74,11 @@ func Require(vm *goja.Runtime, module *goja.Object) {

// Enable adds path to the given runtime.
func Enable(runtime *goja.Runtime) {
runtime.Set("windows", require.Require(runtime, "windows"))
runtime.Set("winlogbeat", require.Require(runtime, "winlogbeat"))
}

func init() {
require.RegisterNativeModule("windows", Require)
require.RegisterNativeModule("winlogbeat", Require)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// +build windows

package winlogbeat
package windows

import (
"testing"
Expand Down
1 change: 0 additions & 1 deletion winlogbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
// Import processors and supporting modules.
_ "github.com/elastic/beats/v7/libbeat/processors/script"
_ "github.com/elastic/beats/v7/libbeat/processors/timestamp"
_ "github.com/elastic/beats/v7/winlogbeat/processors/script/javascript/module/winlogbeat"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
var powershell = (function () {
var path = require("path");
var processor = require("processor");
var winlogbeat = require("winlogbeat");
var windows = require("windows");

var normalizeCommonFieldNames = new processor.Convert({
fields: [
Expand Down Expand Up @@ -183,7 +183,7 @@ var powershell = (function () {
if (!commandLine) {
return;
}
evt.Put(target, winlogbeat.splitCommandLine(commandLine));
evt.Put(target, windows.splitCommandLine(commandLine));
};

var addProcessArgs = function (evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
var security = (function () {
var path = require("path");
var processor = require("processor");
var winlogbeat = require("winlogbeat");
var windows = require("windows");

// Logon Types
// https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/basic-audit-logon-events
Expand Down Expand Up @@ -1670,7 +1670,7 @@ var security = (function () {
if (!cl) {
return;
}
evt.Put("process.args", winlogbeat.splitCommandLine(cl));
evt.Put("process.args", windows.splitCommandLine(cl));
evt.Put("process.command_line", cl);
})
.Build();
Expand Down
4 changes: 2 additions & 2 deletions x-pack/winlogbeat/module/sysmon/config/winlogbeat-sysmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (!String.prototype.startsWith) {
var sysmon = (function () {
var path = require("path");
var processor = require("processor");
var winlogbeat = require("winlogbeat");
var windows = require("windows");
var net = require("net");

// Windows error codes for DNS. This list was generated using
Expand Down Expand Up @@ -311,7 +311,7 @@ var sysmon = (function () {
if (!commandLine) {
return;
}
evt.Put(target, winlogbeat.splitCommandLine(commandLine));
evt.Put(target, windows.splitCommandLine(commandLine));
};

var splitProcessArgs = function (evt) {
Expand Down
1 change: 0 additions & 1 deletion x-pack/winlogbeat/module/testing_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

// Register javascript modules.
_ "github.com/elastic/beats/v7/libbeat/processors/script/javascript/module"
_ "github.com/elastic/beats/v7/winlogbeat/processors/script/javascript/module/winlogbeat"
)

var update = flag.Bool("update", false, "update golden files")
Expand Down