diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-10 13:24:06 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-10 13:24:06 +0000 |
commit | 4a3a5327082b8c284bd5a95cc691778140adb47d (patch) | |
tree | 560bcd23b02099186d8f3da0d8100543bf4789dc | |
parent | 657097cf1b434e26367123dcc7e95486509e9976 (diff) | |
download | acf-snort-4a3a5327082b8c284bd5a95cc691778140adb47d.tar.bz2 acf-snort-4a3a5327082b8c284bd5a95cc691778140adb47d.tar.xz |
Chaning names on tabs, and showing expert config (Applying settings don't work)
git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@529 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | snort-controller.lua | 13 | ||||
-rw-r--r-- | snort-expert-html.lsp | 38 | ||||
-rw-r--r-- | snort-model.lua | 37 | ||||
-rw-r--r-- | snort-status-html.lsp (renamed from snort-read-html.lsp) | 23 | ||||
-rw-r--r-- | snort.menu | 2 |
5 files changed, 99 insertions, 14 deletions
diff --git a/snort-controller.lua b/snort-controller.lua index 880b6d6..199ac4e 100644 --- a/snort-controller.lua +++ b/snort-controller.lua @@ -18,10 +18,9 @@ end -- Public methods -read = function (self) +status = function (self) local srvcmdresult = nil local srvcmd = self.clientdata.srvcmd --- local srvcmd = "start" if (srvcmd ~= nil) then srvcmdresult = self.model:service_control(srvcmd) if (srvcmd == "stop") or (srvcmd == "restart") then @@ -38,3 +37,13 @@ read = function (self) url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end +--[[ +function config(self) + return { status = self.model.getstatus() } +end +--]] + +function expert(self) + return { file = self.model:get_filedetails(), status = self.model.getstatus(),} +end + diff --git a/snort-expert-html.lsp b/snort-expert-html.lsp new file mode 100644 index 0000000..5f5d6ec --- /dev/null +++ b/snort-expert-html.lsp @@ -0,0 +1,38 @@ +<? local view = ... ?> + +<h1>CONFIGURATION</h1> + +<H2>Enable/Disable</H2> +<DT>Change status for this program</DT> +<DD><input class="radio" type="radio" name="enabled" value="2" <? if (view.status.enabled) then io.write('checked') end ?> >Enable +<input class="radio" type="radio" name="enabled" value="3" <? if not (view.status.enabled) then io.write('checked') end ?> >Disable</DD> + +<H2>Expert config</H2> + +<h3>File details</h3> + +<dt>File name</dt> +<dd><?= view.file.details.path ?></dd> + +<dt>File size</dt> +<dd><?= view.file.details.size ?></dd> + +<dt>Last modified</dt> +<dd><?= view.file.details.mtimelong ?></dd> + +<h3>File content</h3> + +<form name="myform" action="" method="POST"> +<input name="name" type=hidden value=""> +<textarea name="modifications"><?= view.file.content ?></textarea> + +<H2>Save and apply above settings</H2> +<DT>Apply settings</DT> +<DD><input class="submitxxx" type="submit" value="Apply"/></DD> + +<? +--[[ DEBUG INFORMATION +require("debugs") +io.write(debugs.variables(view)) +--]] +?> diff --git a/snort-model.lua b/snort-model.lua index b4b3266..9b1300d 100644 --- a/snort-model.lua +++ b/snort-model.lua @@ -6,6 +6,28 @@ module (..., package.seeall) require("posix") require("fs") +local function file_info ( path ) + local filedetails = posix.stat(path) + filedetails["owner"]=rawget((posix.getpasswd(filedetails["uid"])),"name") + filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name") + filedetails["atimelong"]=os.date("%c", filedetails["atime"]) + filedetails["mtimelong"]=os.date("%c", filedetails["mtime"]) + filedetails["path"]=path + filedetails["name"]=basename(path) + + if ( filedetails["size"] > 1073741824 ) then + filedetails["size"]=((filedetails["size"]/1073741824) - (filedetails["size"]/1073741824%0.1)) .. "G" + elseif ( filedetails["size"] > 1048576 ) then + filedetails["size"]=((filedetails["size"]/1048576) - (filedetails["size"]/1048576%0.1)) .. "M" + elseif ( filedetails["size"] > 1024 ) then + filedetails["size"]=((filedetails["size"]/1024) - (filedetails["size"]/1024%0.1)) .. "k" + else + filedetails["size"]=filedetails["size"] + end + return filedetails + +end + local function get_version() local cmd = "snort -V 2>&1 | grep Version | sed 's/.*ersion\ /snort-/'" local cmd_output = io.popen( cmd ) @@ -21,9 +43,7 @@ local is_running = function( process ) local cmdoutput = string.gsub(cmd:read("*a"), "%s", "") cmd:close() if (cmdoutput ~= "") then - statusreport = "Running" - else - statusreport = "Stopped" + statusreport = "Yes" end return statusreport end @@ -35,11 +55,16 @@ getstatus = function (self) local status = {} local version = get_version() status.version = version - local isrunning = is_running("snort") - status.status = isrunning + status.enabled = is_running("snort") return status end - +function get_filedetails() + local filedetails = {} + local path = "/etc/snort/snort.conf" + filedetails.details = file_info(path) + filedetails.content = fs.read_file(path) + return filedetails +end service_control = function ( self, srvcmd ) local srvcmd = string.lower(srvcmd) local retval = "" diff --git a/snort-read-html.lsp b/snort-status-html.lsp index 9bc3b14..8a04f76 100644 --- a/snort-read-html.lsp +++ b/snort-status-html.lsp @@ -1,9 +1,21 @@ <? local view = ... ?> + <h1>SYSTEM INFO</h1> + +<h2>SYSTEM INFO</h2> + +<dt>Program status</dt> +<dd><? if (view.status.enabled) then io.write('Enabled') else io.write('Disabled') end ?></dd> + <dt>Program version</dt> <dd><?= view.status.version ?></dd> -<dt>Process status</dt> -<dd><?= view.status.status ?></dd> + +<H3>PROGRAM SPECIFIC OPTIONS/INFORMATION</H3> +<dt>Counted alerts</dt> +<dd><?= view.alerts ?> alert(s)</dd> + + +<? --[[ ?> <dt>Daemon control</dt> <dd><form action="" method="POST"> <input type=submit name="srvcmd" value="start" class="submit"> @@ -14,10 +26,11 @@ <dt>Previous action</dt> <dd><pre><?= view.srvcmdresult ?></pre></dd> <? end ?> +<? --]] ?> -<h1>ALERT(S)</h1> -<dt>Status</dt> -<dd><?= view.alerts ?> alert(s)</dd> + + +<h1>ALERT LIST</h1> <? for i=1, table.maxn(view.alertresult) do ?> <h2><?= view.alertresult[i]["name"] ?></h2> @@ -1,2 +1,2 @@ #CAT GROUP/DESC TAB ACTION -Applications 80Snort Snort read +Applications 80Snort Snort status |