mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-08 01:59:33 +00:00
Add improved field outputting
Support the notion of a message for all fields in a single class, and making sure it's wrapped as well as the other fields. This is used to display a single message about how indexing working for ka.* filter fields and what IDX_ALLOWED/IDX_NUMERIC/IDX_KEY means, rather than repeating the same text over and over in every field. The wrapping is handled by a function falco::utils::wrap_text. Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
committed by
Leo Di Donato
parent
154dd18c8f
commit
1c3bed135f
55
userspace/engine/falco_utils.cpp
Normal file
55
userspace/engine/falco_utils.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (C) 2016-2018 Draios Inc dba Sysdig.
|
||||
|
||||
This file is part of falco.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with 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.
|
||||
|
||||
*/
|
||||
|
||||
#include "falco_utils.h"
|
||||
|
||||
namespace falco
|
||||
{
|
||||
|
||||
namespace utils
|
||||
{
|
||||
|
||||
std::string wrap_text(const std::string &str, uint32_t initial_pos, uint32_t indent, uint32_t line_len)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
size_t len = str.size();
|
||||
|
||||
for(uint32_t l = 0; l < len; l++)
|
||||
{
|
||||
if(l % (line_len - indent) == 0 && l != 0)
|
||||
{
|
||||
ret += "\n";
|
||||
|
||||
for(uint32_t m = 0; m < indent; m++)
|
||||
{
|
||||
ret += " ";
|
||||
}
|
||||
}
|
||||
ret += str.at(l);
|
||||
}
|
||||
|
||||
ret += "\n";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
|
||||
} // namespace falco
|
Reference in New Issue
Block a user