欢迎

hujl

在Splunk中对数据进行脱敏

在我的很多客户都问过,如何在Splunk中对数据进行脱敏。通常这么做的目的是为了保护个人隐私信息或者符合安全法规的要求。在这篇博客中,我们会讨论在Splunk中对数据进行脱敏的一些方法。 在这篇博客中,我们所有操作都基于以下数据来实现: sourcetype=vendor_sales sample_log: [15/Dec/2016:07:36:56] VendorID=5069 Code=A AcctID=4397877757846973 [15/Dec/2016:07:21:15] VendorID=3108 Code=M AcctID=6347267702474393 其中我们需要将AcctID的前12为隐藏起来,只保留最后4位置 Splunk可以在index phase的时候使用SEDCMD对数据进行脱敏,基于以上实验数据,我们可以用以下配置来实现: props.conf [vendor_sales] SEDCMD-lacct = s/AcctID=\d{12}(\d{4})/AcctID=xxxxxxxxxxxx\1/g 这样Splunk在index数据之前会对AcctID进行脱敏,脱敏后的结果为: sample_log-Masked: [15/Dec/2016:07:36:56] VendorID=5069 Code=A AcctID=xxxxxxxxxxxx6973 [15/Dec/2016:07:21:15] VendorID=3108 Code=M AcctID=xxxxxxxxxxxx4393 TRANSFORMS 在Splunk中同时可以通过transform来实现: 在props.conf中定义transform: props.conf [vendor_sales] TRANSFORMS-anonymize = AcctID-anonymizer 同时在transforms.conf文件中定义脱敏的正则: transforms.conf [AcctID-anonymizer] REGEX = (?m)^(.*)AcctID=\d{12}+(\d{4}.*)$ FORMAT…

Continue reading...
hujl

Too small to match seekptr checksum

用Splunk Monitor文件(xml、html等)的时候,如果文件开始的256bytes是一样的话,Splunk默认会认为是一个文件,从而不会input进index。 用Splunk Monitor文件(xml、html等)的时候,如果文件开始的256bytes是一样的话,Splunk默认会认为是一个文件,从而不会input进index。我们会在$SPLUNK_HOME/var/log/splunkd.log中看到如下的报错: splunkd.log:09-22-2017 01:30:04.522 +0000 ERROR TailReader - File will not be read, is too small to match seekptr checksum (file=/home/ubuntu/logs/json-bowman-<myserver>1-bowman-worker_search-1.log). Last time we saw this initcrc, filename was different. You may wish to use larger initCrcLen for this sourcetype, or a CRC…

Continue reading...
hujl

Collect ldapsearch result to index

当我用collect命令将ldapsearch的结果存入到index的时候遇到一些问题,collect命令并不能很好切分ldapsearch的结果。在collect之前使用table命令将能很好解决这个问题。 我使用以下SPL从ldap上将用户账号信息存放在ldap_summary上,以便日后通过查询使用。(也可以输出为csv,通过lookup来使用,这个不在这里讨论) | ldapsearch domain="xxx-xx.in" search="(&(sAMAccoutName=*))" basedn="OU=AD Account,DC=xxx-xx,DC=in" attrs="sAMAccountName,cn,sn,giveName,emplyeeID,title,department,description,mail,telephoneNumber,memberOt,distinguishedName" | collect index=ldap_summary 结果有一部分按行切分为独立的event,大部分,随机的多行(最多有3000行)合并为一个event,😢 通过多次测试,发现只要在collect命令之前,使用table命令,可以很好的解决这个问题。具体为什么会这样目前还不太清楚。 需改后的SPL如下: | ldapsearch domain="xxx-xx.in" search="(&(sAMAccoutName=*))" basedn="OU=AD Account,DC=xxx-xx,DC=in" attrs="sAMAccountName,cn,sn,giveName,emplyeeID,title,department,description,mail,telephoneNumber,memberOt,distinguishedName" | table sAMAccou ntName,cn,sn,giveName,emplyeeID,title,department,description,mail,telephoneNumber,memberOt,distinguishedName | collect index=ldap_summary

Continue reading...