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

bsmconv #9

Open
wants to merge 219 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
e34d263
Initial commit.
0mp Jun 23, 2016
b5cc74c
Add Makefile.
0mp Jun 23, 2016
70f9d68
Add a simple test script.
0mp Jun 23, 2016
811868c
Add .gitignore.
0mp Jun 23, 2016
18ec943
Fix tests.
0mp Jun 24, 2016
0315ba3
Add records detection.
0mp Jun 24, 2016
ad6dccb
Refactor the code.
0mp Jun 24, 2016
ed3fc69
Remove an _ from a variable name.
0mp Jun 24, 2016
d6d5e7a
Merge pull request #8 from 0mp/bsmconv-refactor
0mp Jun 24, 2016
2519c65
Update tests.
0mp Jun 24, 2016
9ebe626
Prepare to introduce sbuf(9).
0mp Jun 24, 2016
8f97767
Use sbuf. (I cannot compile it though.)
0mp Jun 24, 2016
eafe62b
Separate the records in eventbuf with EOS.
0mp Jun 24, 2016
c99d145
Add -pedantic, -ansi, -Werror and -lsbuf flags.
0mp Jun 24, 2016
b867a86
ANSIfy the code.
0mp Jun 24, 2016
5a7426e
Fix some issues with sbuf.
0mp Jun 25, 2016
e435018
Fix a minor style issue.
0mp Jun 25, 2016
ce8f1d4
Change the way readbuf is allocated.
0mp Jun 25, 2016
bbf30c0
Remove BSMCONV_MSG_FIELD_PREFIX_LEN
0mp Jun 25, 2016
8046f1b
Change iterator variables' names like i to ii.
0mp Jun 25, 2016
c5db626
Change ++i to i++.
0mp Jun 25, 2016
49d5c90
Improve defines.
0mp Jun 25, 2016
ae6db7e
Merge pull request #10 from 0mp/refactor
0mp Jun 25, 2016
7201580
Change Makefile and add pjdlog files from auditdistd.
0mp Jun 25, 2016
b05edf2
Add a script which adds a path to a dependency for pjdlog.
0mp Jun 25, 2016
0157567
Add a pragma to pjdlog.h to ignore not-so-ANSI variadic macros.
0mp Jun 25, 2016
b39f36e
Merge pull request #11 from 0mp/compile-pjdlog
0mp Jun 25, 2016
4429571
Move makefiles to /usr.bin/bsmconv.
0mp Jun 25, 2016
fe54da8
Merge pull request #12 from 0mp/makefile-to-usrbin
0mp Jun 25, 2016
22e1067
Remove -l library from Makefile.
0mp Jun 25, 2016
e468070
Use pjdlog and update runtest.sh.
0mp Jun 25, 2016
446b58f
Merge pull request #13 from 0mp/pjdlogging
0mp Jun 25, 2016
ad432ca
Shorten code lines.
0mp Jun 25, 2016
bbd86d2
Improve log messages.
0mp Jun 25, 2016
fe017ae
Fix minor issues and improve tests.
0mp Jun 25, 2016
f7d9a04
Remove assert.h from bsmconv.c.
0mp Jun 25, 2016
a0aa5dd
Update and rename test script.
0mp Jun 25, 2016
084db43
Add a successfully initialized TAILQ.
0mp Jun 25, 2016
87a11fd
Rename the fu script.
0mp Jun 25, 2016
e49904d
Add extracting of timestamp and id from a record.
0mp Jun 25, 2016
4f6d2e5
Add tests and modify the fu script.
0mp Jun 26, 2016
e755a63
Parse timestamp and id. Clean up before parsing fields.
0mp Jun 26, 2016
43552c6
Fix the sum function of secs and nsecs.
0mp Jun 26, 2016
99f2128
Fix test files. (Used ':' instead of '=' in a record's fields).
0mp Jun 26, 2016
dbb8617
Parse record fields. (In progress.)
0mp Jun 26, 2016
1ad6236
Fix pjdlog_debug usage.
0mp Jun 26, 2016
d1fb920
Remove commas from tests. Add a negative comma test.
0mp Jun 26, 2016
e2cef7f
Improve debug logging. It is possible to control debug level now.
0mp Jun 26, 2016
649faef
Fix fu, the test script.
0mp Jun 26, 2016
4a4f57d
Remove unnecessary defines.
0mp Jun 26, 2016
f3907e1
Fix the progress bar in fu, the test script.
0mp Jun 26, 2016
c0d27c2
Fix fu, the testing script.
0mp Jun 26, 2016
1fe70ea
Fix the sumsecs equation.
0mp Jun 26, 2016
f54a1b8
Update and add some tests.
0mp Jun 26, 2016
11a2b1c
Solve #21 (the issue with errno != 0).
0mp Jun 26, 2016
4780ad6
Add a test and update the test script.
0mp Jun 26, 2016
190709e
Update tests.
0mp Jun 26, 2016
4294bb6
Update tests.
0mp Jun 26, 2016
f6bb9e1
Parse fields of a record.
0mp Jun 26, 2016
695151e
Add linau_record_init and solve some TODOs.
0mp Jun 26, 2016
f618eae
Change mallocs to callocs.
0mp Jun 27, 2016
1430733
Use PJDLOG_VERIFY instead of PJDLOG_ASSERT.
0mp Jun 27, 2016
1db5797
Fix minor issues.
0mp Jun 28, 2016
1e41ef4
Update string_to_unit32().
0mp Jun 28, 2016
cd77f82
Merge pull request #16 from 0mp/tailq
0mp Jun 28, 2016
e07ae4e
Beta parser (#25)
0mp Jun 29, 2016
7f445dd
Add linau_event.c and linau_event.h.
0mp Jun 29, 2016
d6a1ea7
Parse record's type, id and nsecs.
0mp Jun 29, 2016
82697e6
Add gitignore for the makefile directory.
0mp Jun 30, 2016
b513687
Change TAILQ to nvlist in the linau structs.
0mp Jun 30, 2016
4d394e3
Use nvlists to manage fields.
0mp Jun 30, 2016
bccaba1
Update tests.
0mp Jun 30, 2016
b88d739
Rewrite linau_event.
0mp Jun 30, 2016
59c3e32
Rewrite bsmconv.c.
0mp Jun 30, 2016
4846a62
Create & design the interface (in progress).
0mp Jun 30, 2016
39f9c7d
Refactor and implement the interface (in progress).
0mp Jun 30, 2016
9cdfe89
Improve the linau_field interface.
0mp Jul 1, 2016
4613021
Clean up and fix bugs.
0mp Jul 1, 2016
3a77ddd
Fix a bug in linau_record_generate.
0mp Jul 1, 2016
d63a26d
Remove some old code and add a memo.
0mp Jul 1, 2016
d8d8277
Improve the key generation.
0mp Jul 2, 2016
dbf0c29
Pass tests.
0mp Jul 3, 2016
30290b3
Implement the event printing.
0mp Jul 3, 2016
4cb5043
Implement parser beta version.
0mp Jul 3, 2016
d368953
Add comma support. Update tests.
0mp Jul 3, 2016
30df4fb
Fix the issue with trailing spaces.
0mp Jul 3, 2016
6fcdf84
Minor clean-ups.
0mp Jul 3, 2016
80653a7
Merge pull request #26 from 0mp/library-interface
0mp Jul 3, 2016
db92470
Refactor library (#32)
0mp Jul 5, 2016
cac73f2
Improve formatting.
0mp Jul 5, 2016
107bd17
Apply some style(9).
0mp Jul 5, 2016
adda611
Clean up.
0mp Jul 5, 2016
1dc2b5d
Begin to implement linau_event to token conversion.
0mp Jul 5, 2016
dccb0ce
Add a not working version of conversion.
0mp Jul 6, 2016
e5544fb
Make a basic conversion work.
0mp Jul 6, 2016
7ff4135
Remove get_size functions.
0mp Jul 6, 2016
39ccbcb
Clean up.
0mp Jul 6, 2016
9679dbb
Move the test for tabs to the unhandled tests.
0mp Jul 6, 2016
9618a81
Expand the libbsm interface.
0mp Jul 6, 2016
dbadd6a
Minor cleanups.
0mp Jul 6, 2016
8a8a55e
Comment out au_close_buffer_tm.
0mp Jul 6, 2016
844d7ce
Fix get_timeval.
0mp Jul 6, 2016
32637bf
Refactor linau_record_to_au. Debugify bsmconv.
0mp Jul 6, 2016
d3b0e9c
Add LA types defines.
0mp Jul 6, 2016
ab7ba57
Extend the linau_record structure with lr_text.
0mp Jul 7, 2016
4b274a7
Prepare conversion functions.
0mp Jul 7, 2016
9c7aeb7
Bring back the proper bsmconv.c functionalities.
0mp Jul 7, 2016
4fcf6ef
Improve the comment of linau_record_compare_origin.
0mp Jul 7, 2016
631784d
Update tests. Remove newlines from parsed records.
0mp Jul 7, 2016
c4e6149
Make sense of the Event type parameter in header tokens.
0mp Jul 7, 2016
dd185fa
Add a simple question.
0mp Jul 7, 2016
088927f
Update Makefile.
0mp Jul 7, 2016
e58ce26
Modify libbsm/bsm_audit.c and fix bsmconv.c.
0mp Jul 7, 2016
5a0dafb
Apply the style(9) rule about the switch/case FALLTHROUGH comment.
0mp Jul 7, 2016
0f5203f
Extend the linau_record interface. Fix a minor bug.
0mp Jul 7, 2016
ab93b15
Add a real test on a record of the USER_CMD type.
0mp Jul 7, 2016
1a9031f
Merge pull request #37 from 0mp/la2bsmmap
0mp Jul 8, 2016
3382986
Merge pull request #35 from 0mp/expand-libbsm-interace
0mp Jul 8, 2016
ce963f3
Merge pull request #33 from 0mp/linux-conversion
0mp Jul 8, 2016
092b8cb
Apply suggestions from the code review. (#40)
0mp Jul 8, 2016
0e9c3f4
Define fields.
0mp Jul 8, 2016
48f908d
Add a macro which returns the number of arguments.
0mp Jul 8, 2016
5e6d08e
Update the macro.
0mp Jul 8, 2016
80f09db
Extend the linau_record struct with the lr_fields_count field.
0mp Jul 10, 2016
5453f8f
Add a wrapper on pjdlog.h.
0mp Jul 10, 2016
405a7b7
Reorganise the code.
0mp Jul 10, 2016
cdde4d8
Implement a very ugly and incomplete USER_CMD conversion.
0mp Jul 10, 2016
ca4ef00
Add a macro to manage token creation.
0mp Jul 10, 2016
859820f
Fix a bug which failed the au_write assertion.
0mp Jul 11, 2016
816cd8f
Add a proper text token generation for USER_CMD from the msg field.
0mp Jul 11, 2016
057a437
Implement CONVERT_RECORD_TO_AU.
0mp Jul 11, 2016
0a98d75
Improve the file structure.
0mp Jul 11, 2016
0ca5643
Merge pull request #41 from 0mp/la2bsmmap2
0mp Jul 11, 2016
3c9a834
Add structs.
0mp Jul 11, 2016
76b19bc
Improve the linau_impl interface.
0mp Jul 12, 2016
cc3d3b5
Implement the basics of the conversion framework.
0mp Jul 12, 2016
e2f3f64
Implement the conversion of USER_CMD.
0mp Jul 12, 2016
5f84400
Update fu and add a js file with LA notes.
0mp Jul 13, 2016
04e38fe
Work in progress.
0mp Jul 13, 2016
7180aee
Prepare the code for review.
0mp Jul 15, 2016
e136658
Merge pull request #43 from 0mp/improve-linau-conv-api
0mp Jul 15, 2016
229d161
Add a new field (see LA docs (ff07afd)).
0mp Jul 18, 2016
160a0e0
Add some comments on tokens and add USER_START conversion.
0mp Jul 19, 2016
825d959
Add a CRED_REFR conversion.
0mp Jul 19, 2016
96f3b28
Add a support for a CONFIG_CHANGE conversion.
0mp Jul 19, 2016
993ed96
Add a support for the USER_END conversion.
0mp Jul 19, 2016
f21d336
Add support for CRED_DISP.
0mp Jul 19, 2016
cd497bb
Change move functions to set functions.
0mp Jul 19, 2016
4660efb
Fix compliation problems.
0mp Jul 20, 2016
35daedd
Add a macro, fix a bug.
0mp Jul 20, 2016
3c8f5c3
Update documentation.
0mp Jul 20, 2016
3f45379
Add support for the res, result fields.
0mp Jul 20, 2016
01855db
Update test log files.
0mp Jul 20, 2016
45df36d
Update fu.
0mp Jul 21, 2016
b325e52
Add a return token to DAEMON_START.
0mp Jul 21, 2016
f73f261
Improve parsing - skip deprecated 'user'.
0mp Jul 21, 2016
93af1f0
Move definitions to a separate file.
0mp Jul 21, 2016
bd5cac7
Update fu. Improve ./fu t.
0mp Jul 21, 2016
11c2ddb
Move documentation to the docs directory. Use YAML.
0mp Jul 21, 2016
b49695e
Refactor.
0mp Jul 21, 2016
cbc9fbb
Add the USER_AUTH test.
0mp Jul 21, 2016
dbbc2d0
Apply some of Konrad's suggestions (refactoring in progress).
0mp Jul 21, 2016
c97424c
Add a TODO file.
0mp Jul 22, 2016
88964c2
Update docs.
0mp Jul 22, 2016
115f489
Simplify the conversion framework.
0mp Jul 22, 2016
8b686f6
Make progress bar reset before each test in fu and improve comments.
0mp Jul 26, 2016
318c264
Use pjdlog_debug_get and add a todo.
0mp Jul 26, 2016
de4f7bb
Improve line breaks (style).
0mp Jul 26, 2016
71e845b
Perform s/aurecordd/aurd/g.
0mp Jul 26, 2016
05b7544
Refactor linau_conv_get_type_number.
0mp Jul 26, 2016
b6f1c6e
Update docs.
0mp Jul 26, 2016
043ddb5
Add some tests for edge cases.
0mp Jul 26, 2016
d0f99f5
Remove support for non-space whitespace fields separators.
0mp Jul 26, 2016
e5e74a0
Refactor linau_conv.c.
0mp Jul 26, 2016
19d15b5
Update fu.
0mp Jul 28, 2016
4e58944
Add support for every record type in the log files so far.
0mp Jul 28, 2016
a9c55ab
Refactor the while loop in process_events() in bsmconv.c.
0mp Jul 30, 2016
83af40e
Add a STYLE file.
0mp Aug 1, 2016
1515d6c
Refactor the code & improve style. Add a todo.
0mp Aug 1, 2016
f1c0eb2
Improve conversion and style.
0mp Aug 1, 2016
ccbf3e2
Update README.md.
0mp Aug 1, 2016
e62bc68
Add some logs generated on cutting-edge CentOS.
0mp Aug 2, 2016
a1a4ead
Improve fu (generating fields).
0mp Aug 3, 2016
1584b14
Support CWD records.
0mp Aug 3, 2016
cde17f4
Update STYLE.
0mp Aug 3, 2016
44a737c
Improve the path token generation.
0mp Aug 3, 2016
abd20c1
Improve the path token generation.
0mp Aug 3, 2016
c2ab5a0
Update style guide.
0mp Aug 4, 2016
78a2222
Add some todos.
0mp Aug 4, 2016
3ba3802
Improve text formatting in fu.
0mp Aug 4, 2016
0d9fdb0
Update TODO.
0mp Aug 4, 2016
77742d2
Add tests.
0mp Aug 8, 2016
d6dada5
Add a FreeBSD TODO.
0mp Aug 11, 2016
a67d1d6
Improve the process token generation.
0mp Aug 11, 2016
21d10f9
Extend the linau_conv_field interface.
0mp Aug 12, 2016
e77a1ce
Implement the conversion of EXECVE.
0mp Aug 12, 2016
bf1e74f
Try to use the attr token. Fix the path token.
0mp Aug 12, 2016
fdaba71
Improve style (declaration order).
0mp Aug 12, 2016
7b1207a
Replace string_to_uint32() with an abstraction.
0mp Aug 13, 2016
ac0d8f4
Add a simple conversion of PROCTITLE.
0mp Aug 13, 2016
775d3d6
Update the TODO file.
0mp Aug 13, 2016
b153c9c
Update the linau_string_queue interface.
0mp Aug 13, 2016
e044c76
Fix the issue with a fields.
0mp Aug 13, 2016
c5b192e
Improve style.
0mp Aug 13, 2016
37a25ef
Update TODO.
0mp Aug 15, 2016
301c116
Add the a fields to SYSCALL conversion.
0mp Aug 15, 2016
a5c3025
Add the exit token to SYSCALL.
0mp Aug 15, 2016
e18edcd
Improve conversion, comment on event indentifiers.
0mp Aug 15, 2016
564a10c
Add au_to_attr functions to the userland.
0mp Aug 15, 2016
bc9d167
Add the function to convert octal strings to numbers.
0mp Aug 15, 2016
dc2911c
Support the creation of lctoken_attribute.
0mp Aug 15, 2016
9452e3c
Remove an unused function.
0mp Aug 15, 2016
81eaf17
Merge pull request #45 from 0mp/improve-conversion
0mp Aug 15, 2016
d94c3a9
Add a style todo.
0mp Aug 21, 2016
c784358
Update the todo list.
0mp Aug 22, 2016
39a7fc2
Improve style.
0mp Aug 22, 2016
73345f6
Remove old docs.
0mp Aug 22, 2016
bc4d2bf
Add a preamble to the source files.
0mp Aug 22, 2016
5cc8edf
Update STYLE.
0mp Feb 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions contrib/openbsm/bin/bsmconv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
*.core
*.out
3 changes: 3 additions & 0 deletions contrib/openbsm/bin/bsmconv/.tests/unhandled/tabs.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type=TESTTYPE1 msg=audit(1464612294.816:250): name1=value1, name2=value2
type=TESTTYPE2 msg=audit(1464612294.816:250): name1=value1 name2=value2
type=TESTTYPE2 msg=audit(1464612294.816:250): name1=value1 name2=value2
14 changes: 14 additions & 0 deletions contrib/openbsm/bin/bsmconv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Install dependencies

Go to `lib/libbsm` and run:

make
sudo make install

# Compile

./fu m

# Tests

Run `./fu help` to get help on that.
61 changes: 61 additions & 0 deletions contrib/openbsm/bin/bsmconv/STYLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
See the "man: style(99)" file on the project's Wiki on GitHub.

Assertions
==========

General Guidelines
------------------

Use assertions on a parameter of a function when:
- The function is using the parameter directly (like passing the parameter
to strcpy);
- <strike>It calls a function which requires the parameter to be for example
non-NULL. It means that the assertions are supposed to fetch a possible error
as soon as possible.</strike>

`PJDLOG_ASSERT()` vs `PJDLOG_VERIFY()`
--------------------------------------

- Use `PJDLOG_ASSERT()` to check the return value of functions like `malloc()`,
`sbuf_new_auto()` and `au_to_text()` because they fail rarely and there is no
need to use `PJDLOG_VERIFY()` instead.

Brackets
========

The if statements
-----------------

Use a little bit more strict rules in terms of using brackets around the if
statements. Here an example of the desired style:

```c
if (!fun_returning_bool) {
f();
} else {
g();
h();
}

if (!fun_returning_bool) {
f();
} else if (fun_returning_bool2) {
this_is_a_really_long_function_name(withsolongparameters,
thatthelinehastobebroken);
} else {
g();
}

if (f() == 0)
return (1);
else
return (2);

/* It is better to break on "&&" and "||" than on the function's "(". */
if (!very_long_fun(aaa, bbb, ccc) &&
another_very_long_fun(xxx, yyy, zzz)
f();
else if (this_breaking_style_is_not_that_good(xxx, yyy, zzz) && fun(
aaa, bbb, ccc)
f();
```
65 changes: 65 additions & 0 deletions contrib/openbsm/bin/bsmconv/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Conversion
==========

Validation
----------

- [ ] Improve the cwd field value validation. At the moment it checks if
the value is _encoded_. Should it check if the path is actually a valid
path?
- [ ] Regex fields validators should return only valid fields.

Improvements
------------

- [x] Add the Linux Audit record id to a sequence token.
- [ ] Improve the conversion of the LOGIN type record. See an example
in tests/fields.centos.v265/LOGIN.input.
- [ ] Find out what does the _user_ thing mean in a Linux Audit record. Does it
indicate that the user is the subject of the _action_?
- [ ] Some fields like `ses` use the value of `-1` and some others like `auid`
use `?`. What's the rule?
- [ ] Add the identifiers for Linux Audit events so that praudit can generate
meaningful output because of the Linux dedicated identifiers
in `/etc/security/audit_event`.

FreeBSD Improvements
====================

- [ ] Update the `au_token(3)` man page since it is super outdated.
- `au_to_attr` has invalid arguements.
- `man au_to_attr` doesn't open `au_token(3)`. The same applies to
`au_to_attr32`.
- [ ] Why isn't the pointer parameters of the au_to_* functions const? See
`sys/security/audit/bsm_token.c:au_to_exec_args` for example. For example
`au_to_exec_args` does not modify the parameters; as the function uses
`memcpy(3)` it does not _consume_ the parameters.

Maintainability
===============

- [ ] Add a script which validates that every lcrt_tokens list has
a termianting NULL.

Style & Refactoring
===================

- [x] Refactor the while loop in process_events() in bsmconv.c.
- [ ] Standardize the naming convention of static functions.
- May all the interface functions be prefixed with `linau_`.
- [ ] Allign the protypes of static functions (as in style(9)).
- [ ] Should I use protected names (see style(9))?
- [ ] Find out if you should treat int* as an integer or as a pointer as you
sort the variable declarations in functions (see style(9)).
- [ ] Unify the lctokens for the _res_ and _result_ fields.
- [ ] Use pjdlog.h instead of `printf` in `linau_event_dump` (pjdlog.h is said
to cause problems when used together with `printf`).
- [ ] Use pjdlog_set_prefix for pjdlog_debug messages.
- [ ] Use `errx(EX_USAGE, "<usage>");` for usage.

Tests
=====

- [ ] Test if the library properly converts pid fields and uid fields for edge
cases.
- [ ] `argc="text"`
110 changes: 110 additions & 0 deletions contrib/openbsm/bin/bsmconv/bsmconv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*-
* Copyright (c) 2016 Mateusz Piotrowski <[email protected]>
* All rights reserved.
*
* This software was developed by Mateusz Piotrowski during
* the Google Summer of Code 2016 under the mentorship of Konrad Witaszczyk.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#include <sys/time.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <bsm/libbsm.h>

#include "linau.h"
#include "pjdlog.h"

static void process_event(const struct linau_event *event);
static void process_events(FILE *fp);

static void
process_event(const struct linau_event *event)
{
size_t buflen;
u_char *buf;

buf = linau_event_process(event, &buflen);

if (pjdlog_debug_get() == 0)
write(1, buf, buflen);
else
linau_event_dump(event);

free(buf);
}

static void
process_events(FILE *fp)
{
struct linau_event *event;
struct linau_record *record;

event = linau_event_create();
PJDLOG_ASSERT(event != NULL);

/*
* Style: Is this better than the previous while loop?
*/
for (;;) {
record = linau_record_fetch(fp);
if (record == NULL) {
process_event(event);
linau_event_destroy(event);
break;
}
else if (linau_event_compare_origin(event, record) != 0) {
process_event(event);
linau_event_clear(event);
}
linau_event_add_record(event, record);
}
}

int
main(int argc, char **argv)
{
int debuglevel;
int optchar;

pjdlog_init(PJDLOG_MODE_STD);

debuglevel = 0;
while ((optchar = getopt(argc, argv, "v")) != -1)
switch (optchar) {
case 'v':
debuglevel++;
break;
default:
PJDLOG_ABORT("Invalid command line options detected");
}

pjdlog_debug_set(debuglevel);

process_events(stdin);

return (0);
}
111 changes: 111 additions & 0 deletions contrib/openbsm/bin/bsmconv/docs/la-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
fields:
audit_backlog_limit:
name: audit_backlog_limit
type: numeric
notes:
- |
What is it?

https://www.redhat.com/archives/rhl-beta-list/2007-December/msg00449.html
auid:
name: auid
type: numeric
notes:
- meaning: login user id
cmd:
name: cmd
type: encoded
cwd:
name: cwd
type: encoded
notes:
- meaning: The current working directory.
egid:
name: egid
type: numeric
euid:
name: euid
type: numeric
msg:
name: msg
type: alphanumeric
fields:
- cwd
- cmd
- terminal
- res
notes:
- meaning: The payload of the audit record.
- It seems to store additional fields inside its value.
op:
name: op
type: alphanumeric
notes:
- meaning: The operation being performed that is audited.
values:
- open
pid:
name: pid
type: numeric
res:
name: res
type: alphanumeric
values:
- success
- failed
notes:
- |
Inconsistency

According to what was posted on the linux-audit redhat com mailing
list the only valid values are success and fail.
ses:
name: ses
type: numeric
terminal:
name: terminal
type: alphanumeric
recordTypes:
LOGIN:
examples:
- |
type=LOGIN msg=audit(1468853208.803:12): pid=1166 uid=0 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 old auid=4294967295 new auid=0 old ses=4294967295 new ses=1
notes:
- |
This is somewhat weird to see the 'new' and the 'old' words between
fields.
USER_CMD:
obligatory_fields:
- auid
- egid
- euid
- pid
- ses
optional_fields:
tokens:
- function_name: au_to_process32
USER_AUTH:
obligatory_fields:
- auid
- msg
- pid
- ses
- subj:
example_values:
- text,subj=system_u:system_r:local_login_t:s0-s0:c0.c1023
- uid
tokens:
- function_name: au_to_process32
tokens:
process32:
function_name: au_to_process32
notes:
- |
The IP address and the port number of the Linux Audit should be
placed in this token.
standard:
notes:
- |
According to Steve Grubb fields can be separated by only a comma or
a space. There should be no exceptions.
Loading