mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Re-indent some scripts. Whitespace-only commit
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -40,68 +40,68 @@ portrule = shortport.http
|
||||
-- @return author name filtred from html entities
|
||||
---
|
||||
get_owner = function(res)
|
||||
local result=res
|
||||
local _
|
||||
if ( res:match('<span') ) then
|
||||
_,_,result=string.find(res,'title="(.-)"')
|
||||
end
|
||||
return result
|
||||
local result=res
|
||||
local _
|
||||
if ( res:match('<span') ) then
|
||||
_,_,result=string.find(res,'title="(.-)"')
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
|
||||
local path = stdnse.get_script_args(SCRIPT_NAME .. '.path') or '/'
|
||||
local response = http.get(host,port,path)
|
||||
local result, result_stats = {}, {}
|
||||
local path = stdnse.get_script_args(SCRIPT_NAME .. '.path') or '/'
|
||||
local response = http.get(host,port,path)
|
||||
local result, result_stats = {}, {}
|
||||
|
||||
if not response or not response.status or response.status ~= 200 or
|
||||
not response.body then
|
||||
stdnse.print_debug(1, "%s: Failed to retrieve file: %s",
|
||||
SCRIPT_NAME, path)
|
||||
return
|
||||
end
|
||||
if not response or not response.status or response.status ~= 200 or
|
||||
not response.body then
|
||||
stdnse.print_debug(1, "%s: Failed to retrieve file: %s",
|
||||
SCRIPT_NAME, path)
|
||||
return
|
||||
end
|
||||
|
||||
local html = response.body
|
||||
local repo=tab.new()
|
||||
tab.addrow(repo,'PROJECT','AUTHOR','DESCRIPTION')
|
||||
local html = response.body
|
||||
local repo=tab.new()
|
||||
tab.addrow(repo,'PROJECT','AUTHOR','DESCRIPTION')
|
||||
|
||||
-- verif generator
|
||||
if (html:match('meta name="generator" content="gitweb(.-)"')) then
|
||||
result['name'] = string.format("Projects from %s:", host.targetname or host.ip)
|
||||
-- verif generator
|
||||
if (html:match('meta name="generator" content="gitweb(.-)"')) then
|
||||
result['name'] = string.format("Projects from %s:", host.targetname or host.ip)
|
||||
|
||||
local owners, projects_counter, owners_counter = {}, 0, 0
|
||||
local owners, projects_counter, owners_counter = {}, 0, 0
|
||||
|
||||
for tr_code in html:gmatch('(%<tr[^<>]*%>(.-)%</tr%>)') do
|
||||
local regx='<a[^<>]*href="(.-)">(.-)</a>(.-)title="(.-)"(.-)<i>(.-)</i>'
|
||||
for _, project, _, desc, _, owner in tr_code:gmatch(regx) do
|
||||
for tr_code in html:gmatch('(%<tr[^<>]*%>(.-)%</tr%>)') do
|
||||
local regx='<a[^<>]*href="(.-)">(.-)</a>(.-)title="(.-)"(.-)<i>(.-)</i>'
|
||||
for _, project, _, desc, _, owner in tr_code:gmatch(regx) do
|
||||
|
||||
--if desc result return default text of gitweb replace it by no description
|
||||
if(string.find(desc,'Unnamed repository')) then
|
||||
desc='no description'
|
||||
end
|
||||
--if desc result return default text of gitweb replace it by no description
|
||||
if(string.find(desc,'Unnamed repository')) then
|
||||
desc='no description'
|
||||
end
|
||||
|
||||
tab.addrow(repo, project, get_owner(owner), desc)
|
||||
tab.addrow(repo, project, get_owner(owner), desc)
|
||||
|
||||
-- Protect from parsing errors or long owners
|
||||
-- just an arbitrary value
|
||||
if owner:len() < 128 and not owners[owner] then
|
||||
owners[owner] = true
|
||||
owners_counter = owners_counter + 1
|
||||
end
|
||||
if owner:len() < 128 and not owners[owner] then
|
||||
owners[owner] = true
|
||||
owners_counter = owners_counter + 1
|
||||
end
|
||||
|
||||
projects_counter = projects_counter + 1
|
||||
end
|
||||
end
|
||||
projects_counter = projects_counter + 1
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(result,tab.dump(repo))
|
||||
table.insert(result, "")
|
||||
table.insert(result,
|
||||
string.format("Number of projects: %d", projects_counter))
|
||||
if (owners_counter > 0 ) then
|
||||
table.insert(result,
|
||||
string.format("Number of owners: %d", owners_counter))
|
||||
end
|
||||
table.insert(result,tab.dump(repo))
|
||||
table.insert(result, "")
|
||||
table.insert(result,
|
||||
string.format("Number of projects: %d", projects_counter))
|
||||
if (owners_counter > 0 ) then
|
||||
table.insert(result,
|
||||
string.format("Number of owners: %d", owners_counter))
|
||||
end
|
||||
|
||||
end
|
||||
return stdnse.format_output(true,result)
|
||||
end
|
||||
return stdnse.format_output(true,result)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user