mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-30 03:34:26 +03:00
Mar 26th 2023 Dev
This commit is contained in:
41
components/include/env_details.h
Normal file
41
components/include/env_details.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ENV_DETAILS_H__
|
||||
#define __ENV_DETAILS_H__
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <streambuf>
|
||||
|
||||
#include "i_env_details.h"
|
||||
#include "singleton.h"
|
||||
#include "debug.h"
|
||||
|
||||
class EnvDetails : Singleton::Provide<I_EnvDetails>::SelfInterface
|
||||
{
|
||||
public:
|
||||
EnvDetails();
|
||||
|
||||
virtual EnvType getEnvType() override;
|
||||
virtual std::string getToken() override;
|
||||
|
||||
private:
|
||||
std::string retrieveToken();
|
||||
std::string readFileContent(const std::string &file_path);
|
||||
|
||||
std::string token;
|
||||
EnvType env_type;
|
||||
};
|
||||
|
||||
#endif // __ENV_DETAILS_H__
|
@@ -17,11 +17,8 @@
|
||||
class I_LocalPolicyMgmtGen
|
||||
{
|
||||
public:
|
||||
enum class LocalPolicyEnv { LINUX, K8S, COUNT };
|
||||
|
||||
virtual std::string parsePolicy(const std::string &policy_version) = 0;
|
||||
virtual const std::string & getPolicyPath(void) const = 0;
|
||||
virtual LocalPolicyEnv getEnvType() const = 0;
|
||||
|
||||
protected:
|
||||
~I_LocalPolicyMgmtGen() {}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "maybe_res.h"
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
using CBFunction = std::function<void(uint, const PMPattern &)>;
|
||||
|
||||
virtual std::set<PMPattern> scanBuf(const Buffer &buf) const = 0;
|
||||
virtual std::set<std::pair<uint, PMPattern>> scanBufWithOffset(const Buffer &buf) const = 0;
|
||||
virtual std::set<std::pair<uint, uint>> scanBufWithOffset(const Buffer &buf) const = 0;
|
||||
virtual void scanBufWithOffsetLambda(const Buffer &buf, CBFunction cb) const = 0;
|
||||
|
||||
protected:
|
||||
|
@@ -17,23 +17,20 @@
|
||||
#include "config.h"
|
||||
#include "component.h"
|
||||
#include "i_mainloop.h"
|
||||
#include "i_environment.h"
|
||||
#include "i_local_policy_mgmt_gen.h"
|
||||
#include "i_env_details.h"
|
||||
|
||||
class LocalPolicyMgmtGenerator
|
||||
:
|
||||
public Component,
|
||||
Singleton::Provide<I_LocalPolicyMgmtGen>,
|
||||
Singleton::Consume<Config::I_Config>,
|
||||
Singleton::Consume<I_MainLoop>,
|
||||
Singleton::Consume<I_Environment>
|
||||
Singleton::Consume<I_EnvDetails>
|
||||
{
|
||||
public:
|
||||
LocalPolicyMgmtGenerator();
|
||||
~LocalPolicyMgmtGenerator();
|
||||
|
||||
void preload() override;
|
||||
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <sys/types.h>
|
||||
#include "i_pm_scan.h"
|
||||
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
|
||||
Maybe<void> prepare(const std::set<PMPattern> &patterns);
|
||||
std::set<PMPattern> scanBuf(const Buffer &buf) const override;
|
||||
std::set<std::pair<uint, PMPattern>> scanBufWithOffset(const Buffer &buf) const override;
|
||||
std::set<std::pair<uint, uint>> scanBufWithOffset(const Buffer &buf) const override;
|
||||
void scanBufWithOffsetLambda(const Buffer &buf, I_PMScan::CBFunction cb) const override;
|
||||
|
||||
// Line may begin with ^ or $ sign to mark LSS is at begin/end of buffer.
|
||||
|
Reference in New Issue
Block a user