Commit ba38a05a authored by Cool Fire's avatar Cool Fire
Browse files

Added feed trackers for redhat and debian security feeds

parent 23b67d06
Pipeline #45 passed with stage
in 5 minutes and 46 seconds
#!/usr/bin/env ruby
# Plugin that monitors the debian security advisories
class Debiansecurity
require 'mechanize'
require 'nokogiri'
def initialize( status, config, output, irc, timer )
@status = status
@config = config
@output = output
@irc = irc
@timer = timer
@feed_url = 'https://www.debian.org/security/dsa-long'
@feed_etag = ''
@feed_timer = 60
@channel = '#news'
if( @status.threads && @config.threads)
@rss_thread = Thread.new{ check_rss }
end
end
# Default action for this plugin
def main( nick, user, host, from, msg, arguments, con )
end
# Method to be called when the plugin is unloaded
def unload
if( @status.threads && @config.threads)
@rss_thread.exit
end
return true
end
private
def check_rss
while true
begin
agent = Mechanize.new
head = agent.head( @feed_url )
etag = head['ETag']
if(etag != @feed_etag)
@feed_etag = etag
# Grab rss
xml = agent.get( @feed_url ).body
xml = Nokogiri::XML( xml )
# Parse out info
title, link = "", ""
title = xml.css( 'item title' ).first.text
link = xml.css( 'item link' ).first.text
# If the tinyurl plugin is loaded, use it
if( @status.checkplugin( "tinyurl" ) )
plugin = @status.getplugin( "tinyurl" )
link = plugin.main( nil, nil, nil, nil, nil, link, false )
end
@irc.message( @channel, "#{title} | #{link}" )
end
rescue Exception => e
# Silently fail
@output.debug( "Failure while retrieving rss feed: #{e.to_s}\n" )
end
# Wait for a bit before fetching again
sleep( @feed_timer )
end
end
end
\ No newline at end of file
#!/usr/bin/env ruby
# Plugin that monitors the Redhat security errata
class Redhatsecurity
require 'mechanize'
require 'nokogiri'
def initialize( status, config, output, irc, timer )
@status = status
@config = config
@output = output
@irc = irc
@timer = timer
@feed_url = 'https://rhn.redhat.com/rpc/recent-errata.pxt'
@feed_last = ''
@feed_timer = 600
@channel = '#news'
if( @status.threads && @config.threads)
@rss_thread = Thread.new{ check_rss }
end
end
# Default action for this plugin
def main( nick, user, host, from, msg, arguments, con )
end
# Method to be called when the plugin is unloaded
def unload
if( @status.threads && @config.threads)
@rss_thread.exit
end
return true
end
private
def check_rss
while true
begin
agent = Mechanize.new
# Grab rss
xml = agent.get( @feed_url ).body
xml = Nokogiri::XML( xml )
# Parse out info
title, link = "", ""
title = xml.css( 'item title' ).last.text
link = xml.css( 'item link' ).last.text
if(link != @feed_last)
@feed_last = link
# If the tinyurl plugin is loaded, use it
if( @status.checkplugin( "tinyurl" ) )
plugin = @status.getplugin( "tinyurl" )
link = plugin.main( nil, nil, nil, nil, nil, link, false )
end
@irc.message( @channel, "#{title} | #{link}" )
end
rescue Exception => e
# Silently fail
@output.debug( "Failure while retrieving rss feed: #{e.to_s}\n" )
end
# Wait for a bit before fetching again
sleep( @feed_timer )
end
end
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment