Completed
Push — master ( dfc09d...afe5c3 )
by -
01:38
created

atom()   A

Complexity

Conditions 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 8.6667
Metric Value
cc 3
dl 0
loc 12
ccs 1
cts 7
cp 0.1429
crap 8.6667
rs 9.4285
1 1
from flask import Blueprint, redirect, Response, current_app, send_from_directory, request
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
    feed = AtomFeed('Recent rules', feed_url=request.url, url=request.url_root)
28
    _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...
29
    if _rules:
30
        for rule in _rules:
31
            feed.add(title=rule.msg,
32
                     entires=unicode(rule.fullstr()),
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'unicode'
Loading history...
33
                     content_type='text',
34
                     updated=datetime.fromtimestamp(rule.timestamp),
35
                     id=rule.sid)
36
    return feed.get_response()
37