Mercurial > farol
changeset 8:2ce3676c9b2e
Ease the import of new documents
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 25 Sep 2014 17:49:43 +0200 |
parents | 8f41bb7f4681 |
children | 5b84a2c4f30c |
files | CHANGES farol/main.py farol/templates/about.j2 farol/templates/base.j2 farol/templates/new.j2 farol/templates/vulnerability/view_remediation.j2 |
diffstat | 6 files changed, 60 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES Thu Sep 25 17:03:35 2014 +0200 +++ b/CHANGES Thu Sep 25 17:49:43 2014 +0200 @@ -1,3 +1,12 @@ +Farol 0.1.1 (2014-??-??) +======================== + +Main changes since 0.1: +----------------------- +* Ease the import of documents +* Add a Welcome page + + Farol 0.1 (2014-09-24) ======================
--- a/farol/main.py Thu Sep 25 17:03:35 2014 +0200 +++ b/farol/main.py Thu Sep 25 17:49:43 2014 +0200 @@ -87,13 +87,28 @@ def welcome(): return render_template('welcome.j2') +def parse_url(url): + set_current(parse(urlopen(url).read())) + @app.route('/new', methods=['GET', 'POST']) def new(): if request.method != 'POST': return render_template('new.j2', has_document=has_current(), now=utcnow()) - - if 'url' in request.form: - set_current(parse(urlopen(request.form['url']).read())) + url = None + if 'rhsa' in request.form: + year, index = request.form['id'].split(':') + parse_url("https://www.redhat.com/security/data/cvrf/%(year)s/cvrf-rhsa-%(year)s-%(index)s.xml" % {'year': year, 'index': index}) + elif 'oracle' in request.form: + parse_url("http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/%s.xml" % request.form['id']) + elif 'cisco' in request.form: + kind, date, name = request.form['id'].split('-', 3) + kind = {'sa': 'Advisory', 'sr': 'Response'}[kind] + parse_url("http://tools.cisco.com/security/center/contentxml/CiscoSecurity%(kind)s/cisco-%(id)s/cvrf/cisco-%(id)s_cvrf.xml" % {'kind': kind, 'id': request.form['id']}) + elif 'nasl' in request.form: + flash("I'm not able to parse NASL scripts yet", 'danger') + return redirect(url_for('new')) + elif 'url' in request.form: + parse_url(request.form['url']) elif 'local' in request.files: upload = request.files['local'] if not upload.filename.endswith('.xml'):
--- a/farol/templates/about.j2 Thu Sep 25 17:03:35 2014 +0200 +++ b/farol/templates/about.j2 Thu Sep 25 17:49:43 2014 +0200 @@ -45,6 +45,6 @@ <p>If you want to remove this message and the DEBUG Footer alert, but still want to keep the Debug mode on, just set <code>DEBUG_SURE=True</code> in your configuration file.</p> {% endif %} <hr> - <p><strong>Farol</strong> is published under GPLv2+, and is Copyright © <a href="http://greenbone.net">Greenbone Networks GmbH</a>.</p> + <p><strong>Farol</strong> is published under GPLv2+, and is Copyright © Greenbone Networks GmbH.</p> </div> {% endblock %}
--- a/farol/templates/base.j2 Thu Sep 25 17:03:35 2014 +0200 +++ b/farol/templates/base.j2 Thu Sep 25 17:49:43 2014 +0200 @@ -98,7 +98,7 @@ <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> - {% for element in cache | sort %}<li><a href="{{ url_for('load', element=element)}}">{{ element | capitalize }}</a></li>{% endfor %} + {% for element in cache | sort %}<li><a href="{{ url_for('load', element=element)}}">{{ element }}</a></li>{% endfor %} </ul> </li> </ul> @@ -128,7 +128,7 @@ <div class="text-center"> <span class="text-muted">Copyright © 2014 Greenbone Networks GmbH</span> | - <span><a href="{{ url_for('about') }}">About ...</a></span> + <span><a href="{{ url_for('about') }}">About Farol</a></span> </div> <a href="http://greenbone.net/" id="greenbone" class="logo_img text-hide center-block">Greenbone Networks GmbH</a> </footer>
--- a/farol/templates/new.j2 Thu Sep 25 17:03:35 2014 +0200 +++ b/farol/templates/new.j2 Thu Sep 25 17:49:43 2014 +0200 @@ -24,7 +24,7 @@ -#} {% extends "base.j2" %} -{% from "macros.j2" import textinput, textarea %} +{% from "macros.j2" import textinput, textarea, panel %} {% set active='new' %} @@ -42,12 +42,33 @@ <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#fromURL"> - Download document from URL + Download a document from an URL </a> </h4> </div> <div id="fromURL" class="panel-collapse collapse in"> <div class="panel-body"> + <div class="row"> + {% for (type, placeholder) in [ + ('RHSA', 'YYYY:nnnn'), + ('Oracle', 'nnnnnnn'), + ('Cisco', 'sa-YYYYMMDD-xxx'), + ('NASL', '')] %} + <div class="col-lg-3"> + <form role="form" method="POST"> + <input type="hidden" name="{{ type | lower}}"> + <div class="input-group"> + <span class="input-group-addon">{{ type }}: </span> + <input type="text" class="form-control" name="id" placeholder="{{ placeholder }}"> + <span class="input-group-btn"> + <button class="btn btn-primary" type="submit">Download</button> + </span> + </div><!-- /input-group --> + </form> + </div> + {% endfor %} + </div> + <hr> <form role="form" method="POST"> {{ textinput("url", "URL", "https://...", required=True, type="url") }} <button type="submit", class="btn btn-primary">Download</button> @@ -135,4 +156,10 @@ </div> +{% call panel(heading="Load a document from the cache", title=4, collapsible=False) %} +<ul> +{% for element in cache | sort %}<li><a href="{{ url_for('load', element=element)}}">{{ element }}</a></li>{% endfor %} +</ul> +{% endcall %} + {% endblock %}
--- a/farol/templates/vulnerability/view_remediation.j2 Thu Sep 25 17:03:35 2014 +0200 +++ b/farol/templates/vulnerability/view_remediation.j2 Thu Sep 25 17:49:43 2014 +0200 @@ -39,7 +39,7 @@ {{ label_value('URL', remediation._url | urlize) }} </div> {% if remediation._productids or remediation._groupids %} - {% call panel(heading="Products", title=2) %} + {% call panel(heading="Products (%d)" % remediation._productids | length, title=2) %} <ul> {% for productid in remediation._productids %} <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ cvrf.getProductForID(productid)._name }}</a></li>