-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: QNAP NAP parser #2132
Open
nockstarr
wants to merge
2
commits into
splunk:main
Choose a base branch
from
nockstarr:qnap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: QNAP NAP parser #2132
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Nas | ||
|
||
QNAP NAS QTS|QES shares a common syslog format. | ||
|
||
## Key facts | ||
|
||
* RFC3164 | ||
* Program based filter | ||
|
||
## Links | ||
|
||
| Ref | Link | | ||
|----------------|------------------------------------------| | ||
| Splunk Add-on | <https://splunkbase.splunk.com/app/4632> | | ||
|
||
## Sourcetypes | ||
|
||
| sourcetype | notes | | ||
|----------------|-----------------| | ||
| qnap:syslog | QNAP NAS syslog | | ||
|
||
## Sourcetype and Index Configuration | ||
|
||
| key | sourcetype | index | notes | | ||
|----------|----------------|----------------|-----------------| | ||
| qnap_nas | qnap:syslog | infraops | none | |
21 changes: 21 additions & 0 deletions
21
package/etc/conf.d/conflib/syslog/app-syslog-qnap_nas.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
block parser qnap_nas-parser() { | ||
channel { | ||
rewrite { | ||
r_set_splunk_dest_default( | ||
index('infraops') | ||
source("program:qulogd") | ||
sourcetype('qnap:syslog') | ||
vendor('qnap') | ||
product('nas') | ||
template('t_standard') | ||
); | ||
}; | ||
}; | ||
}; | ||
|
||
application qnap_nas[sc4s-syslog-pgm] { | ||
filter { | ||
program('qulogd' type(string) flags(prefix)); | ||
}; | ||
parser { qnap_nas-parser(); }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2019 Splunk, Inc. | ||
# | ||
# Use of this source code is governed by a BSD-2-clause-style | ||
# license that can be found in the LICENSE-BSD2 file or at | ||
# https://opensource.org/licenses/BSD-2-Clause | ||
import random | ||
|
||
from jinja2 import Environment | ||
|
||
from .sendmessage import * | ||
from .splunkutils import * | ||
from .timeutils import * | ||
|
||
env = Environment() | ||
|
||
# <30>Jul 15 18:03:54 NAShostname qulogd[13241]: conn log: Users: admin, Source IP: 10.0.0.1, Computer name: ---, Connection type: HTTP, Accessed resources: ---, Action: Logout | ||
# <30>Jul 15 18:06:46 NAShostname qulogd[13241]: conn log: Users: admin, Source IP: 10.0.0.1, Computer name: localhost, Connection type: SMB, Accessed resources: Multimedia/folder/file.txt, Action: Read | ||
def test_qnap_nas_qts(record_property, setup_wordlist, setup_splunk, setup_sc4s): | ||
host = "{}-{}".format(random.choice(setup_wordlist), random.choice(setup_wordlist)) | ||
|
||
dt = datetime.datetime.now() | ||
iso, bsd, time, date, tzoffset, tzname, epoch = time_operations(dt) | ||
|
||
# Tune time functions | ||
epoch = epoch[:-7] | ||
|
||
mt = env.from_string( | ||
"{{mark}}{{ bsd }} qnap-{{host}} qulogd[13241]: conn log: Users: admin, Source IP: 10.0.0.1, Computer name: localhost, Connection type: SMB, Accessed resources: Multimedia/folder/file.txt, Action: Read" | ||
) | ||
message = mt.render(mark="<27>", bsd=bsd, host=host) | ||
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514]) | ||
|
||
st = env.from_string( | ||
"search _time={{ epoch }} index=infraops sourcetype=qnap:syslog host=qnap-{{host}}" | ||
) | ||
search = st.render(epoch=epoch, host=host) | ||
|
||
resultCount, eventCount = splunk_single(setup_splunk, search) | ||
|
||
record_property("host", host) | ||
record_property("resultCount", resultCount) | ||
record_property("message", message) | ||
|
||
assert resultCount == 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks okay, only one thing we already removed
setup_wordlist
fixture. If you will be ready to update a test I will merge this PR.