modified build.gradle to build RPMs.

This commit is contained in:
iadgovuser26 2020-05-29 17:20:06 -04:00
parent ff955bd499
commit 330af62e98
5 changed files with 123 additions and 42 deletions

View File

@ -1,6 +1,7 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'findbugs' apply plugin: 'findbugs'
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
apply plugin: 'nebula.ospackage'
version = '1.0' version = '1.0'
@ -11,10 +12,10 @@ repositories {
dependencies { dependencies {
compile project(':HIRS_Utils') compile project(':HIRS_Utils')
compile libs.jcommander compile libs.jcommander
compile libs.commons_io
compile libs.log4j2
compileOnly libs.checkstyle compileOnly libs.checkstyle
compileOnly libs.findbugs compileOnly libs.findbugs
testCompile libs.testng testCompile libs.testng
} }
@ -53,3 +54,63 @@ uploadArchives {
} }
} }
} }
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.netflix.nebula:gradle-ospackage-plugin:4.9.3'
}
}
// Produce packages
ospackage {
packageName='tcgeventlogtool'
os=LINUX
arch=NOARCH
version='1.0.0'
release='1'
into '/opt/hirs/eventlog'
user 'root'
fileMode=0755
from(jar.outputs.files) {
into 'lib'
}
from('lib') {
into 'lib'
}
from(configurations.runtime) {
into 'lib'
}
from('scripts') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.bat')
}
into 'scripts'
}
from('docs') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.odt')
}
into 'docs'
}
from('./') {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
into './'
link("/usr/local/bin/elt","/opt/hirs/eventlog/scripts/eventlog.sh",0x755 )
}
buildRpm {
arch = I386
}
buildDeb {
arch = I386
}
}

View File

@ -0,0 +1,8 @@
#!/bin/bash
# Calls the the_tcg_event_tool and passes in parameters
scriptDir=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")
baseDir=${scriptDir%/*}
libDir=$baseDir"/lib/"
jar="tcg_eventlog_tool-1.0.jar";
java -jar $libDir$jar "$@"

View File

@ -37,6 +37,7 @@ public class Commander {
private boolean bPCRs = false; private boolean bPCRs = false;
private boolean bVerify = false; private boolean bVerify = false;
private boolean bHelp = false; private boolean bHelp = false;
private boolean bDone = false;
private String inFile = ""; private String inFile = "";
private String inFile2 = ""; private String inFile2 = "";
@ -103,12 +104,14 @@ public class Commander {
} else { } else {
inFile = args[i++ + 1]; inFile = args[i++ + 1];
inFile2 = args[i++ + 1]; inFile2 = args[i++ + 1];
/*
if (args.length > i + 1) { if (args.length > i + 1) {
if (!args[i + 1].contains("-")) { // pcr filter provided if (!args[i + 1].contains("-")) { // pcr filter provided
eventFilter = args[i++ + 1]; eventFilter = args[i++ + 1];
eventNumber = Integer.parseInt(eventFilter); eventNumber = Integer.parseInt(eventFilter);
} }
} }
*/
bDiff = true; bDiff = true;
} }
break; break;
@ -141,8 +144,8 @@ public class Commander {
break; break;
case FULL_COMMAND_PREFIX + VERSION_STRING: case FULL_COMMAND_PREFIX + VERSION_STRING:
case COMMAND_PREFIX + "v": case COMMAND_PREFIX + "v":
System.out.print("TCG Event Log Parser version " + VERSION_NUMBER); System.out.print("TCG Event Log Parser version " + VERSION_NUMBER + "\n");
bValidArgs = false; bDone = true;
break; break;
case FULL_COMMAND_PREFIX + VERIFY_STRING: case FULL_COMMAND_PREFIX + VERIFY_STRING:
case COMMAND_PREFIX + "V": case COMMAND_PREFIX + "V":
@ -153,9 +156,9 @@ public class Commander {
bHex = true; bHex = true;
break; break;
case FULL_COMMAND_PREFIX + HELP_STRING: case FULL_COMMAND_PREFIX + HELP_STRING:
case COMMAND_PREFIX + "h":
bHelp = true; bHelp = true;
break; break;
case COMMAND_PREFIX + "h":
default: default:
printHelp(""); printHelp("");
bValidArgs = false; bValidArgs = false;
@ -171,14 +174,20 @@ public class Commander {
public final boolean hasArguments() { public final boolean hasArguments() {
return hasArguments; return hasArguments;
} }
/** /**
* Getter for the input All flag. * Getter for the validity of the commands.
* @return true if the All flag was set. * @return true if the All flag was set.
*/ */
public final boolean getValidityFlag() { public final boolean getValidityFlag() {
return bValidArgs; return bValidArgs;
} }
/**
* Getter for the Done flag.
* @return true if the Done flag was set.
*/
public final boolean getDoneFlag() {
return bDone;
}
/** /**
* Getter for the help flag. * Getter for the help flag.
* @return true if the Help flag was set. * @return true if the Help flag was set.
@ -193,7 +202,6 @@ public class Commander {
public final boolean getPCRFlag() { public final boolean getPCRFlag() {
return bPCRs; return bPCRs;
} }
/** /**
* Getter for the input associated with the Event flag. * Getter for the input associated with the Event flag.
* @return true if the Event Flag was set. * @return true if the Event Flag was set.
@ -201,7 +209,6 @@ public class Commander {
public final boolean getContentFlag() { public final boolean getContentFlag() {
return bContentHex; return bContentHex;
} }
/** /**
* Getter for the input associated with the Event Hex flag. * Getter for the input associated with the Event Hex flag.
* @return true if the Hex Flag was set. * @return true if the Hex Flag was set.
@ -216,7 +223,6 @@ public class Commander {
public final boolean getHexFlag() { public final boolean getHexFlag() {
return bHex; return bHex;
} }
/** /**
* Getter for the input associated with the EventIds flag. * Getter for the input associated with the EventIds flag.
* @return true of EventIds Flag was set. * @return true of EventIds Flag was set.
@ -224,7 +230,6 @@ public class Commander {
public final boolean getEventIdsFlag() { public final boolean getEventIdsFlag() {
return bEventIds; return bEventIds;
} }
/** /**
* Getter for the input associated with the File flag. * Getter for the input associated with the File flag.
* @return true if File Flag was set. * @return true if File Flag was set.
@ -239,7 +244,6 @@ public class Commander {
public final boolean getDiffFlag() { public final boolean getDiffFlag() {
return bDiff; return bDiff;
} }
/** /**
* Getter for the input associated with the Verify flag. * Getter for the input associated with the Verify flag.
* @return true if the verify flag was set * @return true if the verify flag was set
@ -324,9 +328,9 @@ public class Commander {
+ "\n\t\t\t Following parameter MUST be a path and file name." + "\n\t\t\t Following parameter MUST be a path and file name."
+ "\n\t\t\t The local Event Log file will be used if this option is not present." + "\n\t\t\t The local Event Log file will be used if this option is not present."
+ "\n\t\t\t Note: Access to the local Event Log may require admin privileges.\n" + "\n\t\t\t Note: Access to the local Event Log may require admin privileges.\n"
+ " -e\t--event\t\t Display event descriptions (including event content) in " + " -e\t--event\t Display event descriptions (including event content) in "
+ "human readable form." + "human readable form."
+ "\n\t\t\t Following optional parameter is a single pcr id used to filter" + "\n\t\t\t Following optional parameter is a single event number used to filter"
+ " the output." + " the output."
+ "\n\t\t\t All events will be displayed if the optional parameter is not +" + "\n\t\t\t All events will be displayed if the optional parameter is not +"
+ "provided.\n" + "provided.\n"
@ -344,7 +348,7 @@ public class Commander {
+ "\n\t\t\t No following parameters will display all PCRs.\n" + "\n\t\t\t No following parameters will display all PCRs.\n"
+ " -v\t--version\t Parser Version.\n" + " -v\t--version\t Parser Version.\n"
// + " -V\t--Verify\t Attempts to verify the log file against values." // + " -V\t--Verify\t Attempts to verify the log file against values."
+ " -x\t--hex\t\t Displays output in hex format." + " -x\t--hex\t\t Displays event in hex format. Use with -ec to get content."
+ "\n\t\t\t Use -e -ec and -ex options to filter output." + "\n\t\t\t Use -e -ec and -ex options to filter output."
+ "\n\t\t\t All output will be human readble form if not present." + "\n\t\t\t All output will be human readble form if not present."
+ "\n\n"); + "\n\n");

View File

@ -26,21 +26,24 @@ final class Main {
private static byte[] eventLog = null; private static byte[] eventLog = null;
private static boolean bContentFlag, bEventFlag, bHexEvent, bHexFlag, bPcrFlag = false; private static boolean bContentFlag, bEventFlag, bHexEvent, bHexFlag, bPcrFlag = false;
/** /**
* Main Constructor. * Main Constructor.
* @param args command line parameters. * @param args command line parameters.
*/ */
public static void main(final String[] args) { public static void main(final String[] args) {
commander = new Commander(args); commander = new Commander(args);
if (!commander.getValidityFlag()) { if (!commander.getValidityFlag()) {
System.out.print("Program exiting wihtout processs due to issues with" System.out.print("Program exiting wihtout processs due to issues with"
+ " parameters provided."); + " parameters provided.");
System.exit(1); System.exit(1);
}
if (commander.hasArguments()) {
if (commander.getDoneFlag()) {
System.exit(0);
} }
if (commander.hasArguments()) {
if (commander.getHelpFlag()) { if (commander.getHelpFlag()) {
commander.printHelp(""); commander.printHelp("");
System.exit(1); System.exit(0);
} }
if (commander.getOutputFlag()) { if (commander.getOutputFlag()) {
try { try {
@ -80,10 +83,10 @@ final class Main {
if (commander.getHexFlag()) { if (commander.getHexFlag()) {
bHexFlag = true; bHexFlag = true;
} }
} else { } else {
System.out.print("Nothing to do: No Parameters provided."); System.out.print("Nothing to do: No Parameters provided.");
System.exit(1); System.exit(1);
} // End commander processing } // End commander processing
try { try {
if (eventLog == null) { if (eventLog == null) {
@ -123,19 +126,23 @@ final class Main {
+ evLog.getEventList().size() + " events:\n\n"); + evLog.getEventList().size() + " events:\n\n");
} }
} }
int eventCount = 0;
for (TpmPcrEvent event: evLog.getEventList()) { for (TpmPcrEvent event: evLog.getEventList()) {
if ((commander.getEventNumber() == event.getPcrIndex()) if ((commander.getEventNumber() == eventCount++)
|| commander.getEventNumber() == -1) { || commander.getEventNumber() == -1) {
if (bHexFlag) { if ((commander.getPcrNumber() == event.getPcrIndex())
if (bEventFlag || bHexEvent) { || commander.getPcrNumber() == -1) {
writeOut(HexUtils.byteArrayToHexString(event.getEvent()) + "\n"); if (bHexFlag) {
} if (bEventFlag || bHexEvent) {
if (bContentFlag) { writeOut(HexUtils.byteArrayToHexString(event.getEvent()) + "\n");
writeOut(HexUtils.byteArrayToHexString(event.getEventContent()) }
+ "\n"); if (bContentFlag) {
} writeOut(HexUtils.byteArrayToHexString(event.getEventContent())
} else { + "\n");
writeOut(event.toString(bEventFlag, bContentFlag, bHexEvent) + "\n"); }
} else {
writeOut(event.toString(bEventFlag, bContentFlag, bHexEvent) + "\n");
}
} }
} }
} }
@ -218,6 +225,7 @@ final class Main {
byte[] evLog = openLog(logFileName1); byte[] evLog = openLog(logFileName1);
byte[] evLog2 = openLog(logFileName2); byte[] evLog2 = openLog(logFileName2);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
bHexFlag = commander.getHexFlag();
try { try {
eventLog1 = new TCGEventLog(evLog); eventLog1 = new TCGEventLog(evLog);
} catch (Exception e) { } catch (Exception e) {