Git Product home page Git Product logo

guard-project / lcp Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 1.17 MB

In each local agent, the control plane is responsible for programmability, i.e., changing the behaviour of the data plane at run-time.

Home Page: https://guard-lcp.readthedocs.io

License: MIT License

Python 98.96% Shell 1.04%
programmability elasticsearch logstash beats agent log data security management control ebpf

lcp's Introduction

Local Control Plane

License Code size Repository Size Release Docker image Docs

In each local agent, the control plane is responsible for programmability, i.e., changing the behaviour of the data plane at run-time.



Guide

See the Swagger Schema for more details about the REST endpoints and relative formats and requirements of request and response.

Installation

  1. Prerequisite

    • python3
    • pip3
  2. Clone the repository.

    git clone https://gitlab.com/guard-repositories/lcp.git
    cd lcp
  3. Install the dependencies (optional).

    pip3 install -r requirements.txt

Configuration

The configurations are stored in the config.ini file.

Section Setting Default value Note
local-control-plane host 0.0.0.0 IP address to accept requests.
local-control-plane port 4000 TCP port to accept requests.
local-control-plane https false Accept only HTTPS requests.
auth enabled true Enable JWT authentication.
auth header-prefix GUARD Header prefix for JWT authentication.
auth secret-key guard-secret-key Secret key for JWT authentication.
elastic-apm enabled false Enable Elastic APM integration.
elastic-apm server http://localhost:8200 Elastic APM server.
polycube host localhost IP address to contact the polycube installation.
polycube port 9000 Port address to contact the polycube installation.
polycube timeout 20s Timeout for the connection to polycube.
log config log.yaml Path of the log configuration file.

Usage

Display help

python3 main.py -h

Execute

python3 main.py

Extra

See the Issues for features in development.

lcp's People

Contributors

alexcarrega avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

lcp's Issues

Modifying parameters not present in config file (yaml, json, maybe more)

let's assume that agent has parameters like:

param_a
param_b

if the configuration looks like

//config.json
{  
 "param_a": 777
}

and we want to modify param_b which is not present in this config.json (or .yaml) by calling CB API:

PUT http://server/instance/agent/myagent@myexecenv

{
  "id": "myagent@myexecenv",
  "operations": [
    {
      "parameters": [
        {
          "id": "param_b",
          "value": 2
        }
      ]
    }
  ]
}

this line:

old_value = d[path[-1]]

will throw an KeyError which is not caught. If parameter is not found in path than it should be added to the path.

"/config" for actions expects "args" to be an array, but the schema states it is a string

The problem is the line here:

run = ' '.join([cmd] + data.get('args', []))

while the schema states:

lcp/swagger/schema.yaml

Lines 37 to 42 in e44d06e

Config_Action_Request:
properties:
args:
description: Single command argument.
example: -al
type: string

if args is a string then [cmd] + data.get('args', []) for non-empty args returns an error (concatenating list and string).

For me args as an array look better, at least at the first glance.

double 'error' field in response

Problem in lines:

lcp/resource/config.py

Lines 79 to 80 in e44d06e

output.update(error=proc.returncode != 0, executed=run,
return_code=proc.returncode, duration=time.time() - start)

lcp/lib/response.py

Lines 25 to 35 in e44d06e

class Base_Response(object):
error = False
def __init__(self, message, error=False, exception=None, **kwargs):
self.data = dict(message=message)
if exception is not None:
self.data.update(exception=extract_info(exception))
self.data.update(kwargs)
def __data(self):
return expand(self.data, status=self.status(), code=self.code, error=self.error)

and

lcp/utils/sequence.py

Lines 15 to 16 in e44d06e

def expand(elements, **kwrds):
return dict(**elements, **kwrds)

For the Content_Response(output).add(resp) output already contains a field error. But Base_Response in __init__ also has an optional argument error. When the __data method is executed we get an error:

type object got multiple values for keyword argument 'error'

because error is passed in self.data and error=self.error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.