atom()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
c 2
b 0
f 0
dl 0
loc 9
ccs 5
cts 7
cp 0.7143
crap 3.2098
rs 9.6666
1 1
from flask import Blueprint, redirect, Response, current_app, send_from_directory, request, url_for
2 1
from werkzeug.contrib.atom import AtomFeed
0 ignored issues
show
Configuration introduced by
The import werkzeug.contrib.atom could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
3 1
from datetime import datetime
4
5 1
from spike.model.naxsi_rules import NaxsiRules
6
7 1
default = Blueprint('default', __name__)
8
9
10 1
@default.route("/")
11
def index():
12 1
    return redirect("/rules")
13
14
15 1
@default.route("/download")
16
def download():
17 1
    return send_from_directory(directory=current_app.root_path, filename='rules.db', as_attachment=True)
18
19
20 1
@default.route("/robots.txt")
21
def robots():
22 1
    return Response('User-agent: *\n Disallow: /', mimetype='text/plain')
23
24
25 1
@default.route('/rules.atom')
26
def atom():
27 1
    feed = AtomFeed(title='Recent rules', feed_url=request.url, url=request.url_root, author='Spike',
28
                    icon=url_for('static', filename='favicon.ico'))
29 1
    _rules = NaxsiRules.query.order_by(NaxsiRules.sid.desc()).limit(15).all()
0 ignored issues
show
Bug introduced by
The Class NaxsiRules does not seem to have a member named query.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
30 1
    if _rules:
31
        for rule in _rules:
32
            feed.add(rule.msg, str(rule), updated=datetime.fromtimestamp(rule.timestamp), id=rule.sid)
33
    return feed.get_response()
34