From 4a3a5327082b8c284bd5a95cc691778140adb47d Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 10 Jan 2008 13:24:06 +0000 Subject: 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 --- snort-controller.lua | 13 ++++++++++-- snort-expert-html.lsp | 38 ++++++++++++++++++++++++++++++++++ snort-model.lua | 37 ++++++++++++++++++++++++++++------ snort-read-html.lsp | 43 --------------------------------------- snort-status-html.lsp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ snort.menu | 2 +- 6 files changed, 137 insertions(+), 52 deletions(-) create mode 100644 snort-expert-html.lsp delete mode 100644 snort-read-html.lsp create mode 100644 snort-status-html.lsp 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 @@ + + +

CONFIGURATION

+ +

Enable/Disable

+
Change status for this program
+
>Enable + >Disable
+ +

Expert config

+ +

File details

+ +
File name
+
+ +
File size
+
+ +
Last modified
+
+ +

File content

+ +
+ + + +

Save and apply above settings

+
Apply settings
+
+ + 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-read-html.lsp deleted file mode 100644 index 9bc3b14..0000000 --- a/snort-read-html.lsp +++ /dev/null @@ -1,43 +0,0 @@ - -

SYSTEM INFO

-
Program version
-
-
Process status
-
-
Daemon control
-
- - -
- - -
Previous action
-
- - -

ALERT(S)

-
Status
-
alert(s)
- - -

- -

- -


- -
- - (This alarm is repeated times)

- - - - - - - diff --git a/snort-status-html.lsp b/snort-status-html.lsp new file mode 100644 index 0000000..8a04f76 --- /dev/null +++ b/snort-status-html.lsp @@ -0,0 +1,56 @@ + + +

SYSTEM INFO

+ +

SYSTEM INFO

+ +
Program status
+
+ +
Program version
+
+ +

PROGRAM SPECIFIC OPTIONS/INFORMATION

+
Counted alerts
+
alert(s)
+ + + +
Daemon control
+
+ + +
+
+ +
Previous action
+
+ + + + + +

ALERT LIST

+ + +

+ +

+ +


+ +
+ + (This alarm is repeated times)

+ + + + + + + diff --git a/snort.menu b/snort.menu index 27afba7..308d952 100644 --- a/snort.menu +++ b/snort.menu @@ -1,2 +1,2 @@ #CAT GROUP/DESC TAB ACTION -Applications 80Snort Snort read +Applications 80Snort Snort status -- cgit v1.2.3