1
votes

I'm trying to run the following code below and it keeps failing with the error from the title:

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 670, in respond response.body = self.handler() File "/usr/local/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 217, in call self.body = self.oldhandler(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 61, in call return self.callable(*self.args, **self.kwargs) File "web/800-53-server.py", line 79, in family control_list.append('%s-%d - %s' % (id, control, id, control, sc.title.title)) AttributeError: 'NoneType' object has no attribute 'title'

The code block it seems to error on is below:

@cherrypy.expose
def family(self, id="AC", format="html"):
    id = id.upper()
    family_control_count =  {"AC": 25, "AU": 16, "AT": 5, "CM": 11, "CP": 13, "IA": 11, "IR": 10, "MA": 6, "MP": 8,
        "PS": 8, "PE": 20, "PL": 9, "PM": 16, "RA": 6, "CA": 9, "SC": 44, "SI": 17, "SA": 22}
    families = {"AC": "Access Control", "AU": "Audit and Accountability", "AT": "Awareness and Training", "CM": "Configuration Management",
        "CP": "Contingency Planning", "IA": "Identification and Authentication", "IR": "Incident Response", "MA": "Maintenance",
        "MP": "Media Protection", "PS": "Personnel Security", "PE": "Physical and Environmental Protection", "PL": "Planning",
        "PM": "Program Management", "RA": "Risk Assessment", "CA": "Security Assessment and Authorization",
        "SC": "System and Communications Protection", "SI": "System and Information Integrity", "SA": "System and Services Acquisition"}

    control_list = []
    for control in range(1,family_control_count[id]+1):
        sc = SecControl("%s-%d" % (id, control))
        control_list.append('<div><a href="/control?id=%s-%d">%s-%d</a> - %s</div>' % (id, control, id, control, sc.title.title))

    return """<html>

More of the program below:

`#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, os.path
import sys
import random
import string
import json
import yaml
import cherrypy
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('web/templates'))

sys.path.append(os.path.join('lib'))
sys.path.append(os.path.join('data'))
from seccontrol import SecControl
from seccontrolviz import SecControlViz
from utilities import *


class StringGenerator(object):
    @cherrypy.expose
    def index(self):
        return """<html>
          <head>
            <title>800-53 Controls</title>
            <link rel="stylesheet" type="text/css" href="/assets/css/main.css">
          </head>`
1
You Access to sc.title.title It seems that maybe sc. or. Sc.title are None. Have you tried printing them?Gabriel M
I think that maybe because title is repeated twice?Gabriel M
Thanks Gabriel, I took title out but it was still messing up. The strange thing is it works just fine on my macOS laptop but when I try to run it in Ubuntu or Debian with the same Python (2.7.x) version I get this issueTbalz
I'd assume the issue is that the SecControl function is returning None but without seeing what that function is, I can't help further.Zev
It may be useful if you compare the python packages installed un both machines. Using pip freeze. Maybe it is a problem with different versionsGabriel M

1 Answers

2
votes

The package GovReady (which I'm assuming this is using based on the import statements) relies on xsltproc. It is likely that you have it installed on your mac OS but not on the other machines. It needs to be installed with sudo apt install xsltproc or equivalent for your flavor of Linux because it is not a pip package.

Try running xsltproc --stringparam controlnumber 'AC-1' control2json.xsl ../data/800-53-controls.xml from your 800-53-server/lib directory. The function you are calling is a wrapper for that command.

After installing that program, I get

{ "id": "AC-1",
  "title": "ACCESS CONTROL POLICY AND PROCEDURES",
...
}