Ejemplo n.º 1
0
 def put(self, id):
     data = request.get_json()["policy"]
     policy = tracked_services.get(id)
     if not id or not policy:
         abort(404)
     policy.policy = data["policy"]
     policy.save()
     return jsonify(policy=policy.serialized)
Ejemplo n.º 2
0
 def get(self, id):
     svcs = tracked_services.get(id)
     if id and not svcs:
         abort(404)
     if isinstance(svcs, tracked_services.SecurityPolicy):
         return jsonify(policy=svcs.serialized)
     else:
         return jsonify(policies=[x.serialized for x in svcs])
Ejemplo n.º 3
0
 def put(self, id):
     data = json.loads(request.data)["policy"]
     policy = tracked_services.get(id)
     if not id or not policy:
         abort(404)
     policy.policy = data["policy"]
     policy.save()
     return jsonify(policy=policy.as_dict())
Ejemplo n.º 4
0
def block(id):
    """Block all network access to service"""
    try:
        svc = tracked_services.get(id)
        svc.policy = 0
        svc.save()
        logger.success('ctl:sec:block', 'Access to {0} blocked'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Ejemplo n.º 5
0
def local(id):
    """Allow local network access only to service"""
    try:
        svc = tracked_services.get(id)
        svc.policy = 1
        svc.save()
        logger.success('ctl:sec:local', 'Access to {0} restricted'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Ejemplo n.º 6
0
def allow(id):
    """Allow all access to service"""
    try:
        svc = tracked_services.get(id)
        svc.policy = 2
        svc.save()
        logger.success('ctl:sec:allow', 'Access to {0} allowed'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Ejemplo n.º 7
0
 def get(self, id):
     websites.get()
     svcs = tracked_services.get(id)
     if id and not svcs:
         abort(404)
     if type(svcs) == list:
         return jsonify(policies=[x.as_dict() for x in svcs])
     else:
         return jsonify(policy=svcs.as_dict())
Ejemplo n.º 8
0
def initial_scans():
    """Setup initial scans for all arkOS objects."""
    from arkos import applications, backup, certificates, databases, websites
    from arkos import tracked_services
    applications.scan(cry=False)
    backup.get()
    certificates.scan()
    databases.scan()
    websites.scan()
    tracked_services.initialize()
    if config.get("general", "enable_upnp"):
        tracked_services.initialize_upnp(tracked_services.get())
Ejemplo n.º 9
0
def list_policies():
    """List security policies"""
    try:
        data = [x.serialized for x in tracked_services.get()]
        for x in data:
            pol, fg = ("Allow All", "green") if x["policy"] == 2 else \
                (("Local Only", "yellow") if x["policy"] == 1 else
                    ("Restricted", "red"))
            click.echo(
                click.style(x["name"], fg="green", bold=True) +
                click.style(" (" + x["id"] + ")", fg="yellow"))
            click.echo(click.style(" * Type: ", fg="yellow") + x["type"])
            click.echo(
                click.style(" * Ports: ", fg="yellow") + ", ".join(
                    ["{0} {1}".format(y[1], y[0].upper())
                     for y in x["ports"]]))
            click.echo(
                click.style(" * Policy: ", fg="yellow") +
                click.style(pol, fg=fg))
    except Exception as e:
        raise CLIException(str(e))
Ejemplo n.º 10
0
 def delete(self, id):
     policy = tracked_services.get(id)
     if not id or not policy or policy.type != "custom":
         abort(404)
     policy.remove()
     return jsonify(), 204