blob: 655e7dee56a5d3025986a317de496fe059f2a9ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# /usr/bin/env ruby
# 安全 [anzen] aka security.gentoo.org
# Alex Legler <a3li@gentoo.org>
# AGPLv3
require 'bundler/setup'
require 'yaml'
require 'singleton'
require 'nokogiri'
require 'sinatra'
require 'sinatra/partial'
require_relative 'lib/helpers.rb'
require_relative 'lib/glsa_repository.rb'
configure do
set :partial_template_engine, :erb
mime_type :atom, 'application/atom+xml'
end
# Implicitly load advisories
GLSARepository.instance
BASE_URL = 'https://security.gentoo.org/'.freeze
get '/glsa/?' do
@ids = GLSARepository.instance.get.keys.reverse
@nav = :glsa
erb :glsa
end
get '/glsa/feed.:format' do
items = GLSARepository.instance.get.values.reverse[0..50]
case params[:format]
when 'atom'
content_type :atom
feed('atom', items)
when 'rss1'
content_type :xml
feed('1.0', items)
when 'rss', 'rss2'
content_type :xml
feed('2.0', items)
else
status 404
body 'Feed not available.'
return
end
end
get '/glsa/:glsaid.xml' do
if params[:glsaid] =~ /^\d{6}-\d{2}$/ and GLSARepository.instance.has? params[:glsaid]
send_file(File.join(File.dirname(__FILE__), 'data/glsa/glsa-' + params[:glsaid] + '.xml'), type: :xml)
else
status 404
body 'GLSA not found.'
return
end
end
get '/glsa/:glsaid' do
if GLSARepository.instance.has? params[:glsaid]
if params[:passthru] == '1'
redirect "/glsa/#{params[:glsaid]}.xml"
return
end
@glsa = GLSARepository.instance[params[:glsaid]]
template = :glsa
if @glsa.is_a? GLSAv1
template = :'glsa/glsav1'
end
@nav = :glsa
erb template
else
status 404
body 'GLSA not found.'
return
end
end
get '/subscribe' do
@nav = :subscribe
erb :subscribe
end
get '/' do
@ids = GLSARepository.instance.get.keys.reverse
@nav = :index
erb :index
end
get '/update' do
GLSARepository.instance.update!
'ok'
end
|