1 #!/usr/perl5/bin/perl -w
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 # audit_record_xml [-d] <xml input file>
29 # audit_record_xml takes the audit record description (.xml file) and
30 # generates adt_ part of audit_record_attr on stdout.
38 our $debug = 0; # normal use is to set via the file being parsed.
39 # <debug set="on"/> or <debug set="off"/> or <debug/>
40 # if the set attribute is omitted, debug state is toggled
41 # Override with appDebug, but toggle won't do what you
43 my $appDebug = 0; # used after return from "new auditxml";
45 my $prog = $0; $prog =~ s|.*/||g;
46 my $usage = "usage: $prog [-d] file.xml\n";
52 die $usage if ($#ARGV < 0);
54 my $doc = new auditxml ($ARGV[0]); # input XML file
58 foreach my $eventId ($doc->getEventIds) {
59 my $event = $doc->getEvent($eventId);
60 next if ($event->getOmit eq 'always');
61 print "label=$eventId\n";
62 my $title = $event->getTitle;
63 print " title=$title\n" if (defined $title && length($title));
64 my $program = $event->getProgram;
65 if (defined $program && scalar @$program) {
67 print join(";", @$program);
70 my $see = $event->getSee;
71 if (defined $see && scalar @$see) {
73 print join(";", @$see);
79 my $superClass = $event->getSuperClass;
80 $event = $superClass if (defined $superClass && ref($superClass));
81 foreach my $entryId ($event->getExternal->getEntryIds) {
82 next if $entryId eq 'subject';
83 next if $entryId eq 'return';
84 my @entry = $event->getExternal->getEntry($entryId);
85 my $token = $entry[2];
86 my $comment = $entry[4];
87 my $opt = $entry[0]->getAttr('opt');
88 $token = "[$token]" if ($opt eq 'optional');
89 if (defined $comment && ($comment ne '')) {
92 push @$comments, $comment;
94 push @$format, $token;
96 if (scalar @$format) {
97 print " format=".join(":", @$format)."\n";
99 print " format=user\n";
102 foreach (@$comments) {
103 $commentStr .= " comment=$_:\n";
105 $commentStr =~ s/:\n$/\n/s;