Skip to content

Commit baf311c

Browse files
authored
fix handling of container metadata in "infra" events [SMAGENT-1647] (#1418)
* fix handling of container metadata in "infra" events. * address review comments. look for "sha256" instead.
1 parent a6ab1e6 commit baf311c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

userspace/libsinsp/filterchecks.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,12 +4442,16 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
44424442
vector<string> subelements = sinsp_split(e, ':');
44434443
ASSERT(subelements.size() == 2);
44444444
m_strstorage = trim(subelements[1]);
4445+
if(m_strstorage.length() > 12)
4446+
{
4447+
m_strstorage = m_strstorage.substr(0, 12);
4448+
}
44454449
RETURN_EXTRACT_STRING(m_strstorage);
44464450
}
44474451
}
44484452
else if(m_field_id == TYPE_INFRA_DOCKER_CONTAINER_NAME)
44494453
{
4450-
if(e.substr(0, sizeof("Name") - 1) == "Name")
4454+
if(e.substr(0, sizeof("name") - 1) == "name")
44514455
{
44524456
vector<string> subelements = sinsp_split(e, ':');
44534457
ASSERT(subelements.size() == 2);
@@ -4461,7 +4465,17 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
44614465
{
44624466
vector<string> subelements = sinsp_split(e, ':');
44634467
ASSERT(subelements.size() == 2);
4464-
m_strstorage = trim(subelements[1]);
4468+
m_strstorage = subelements[1];
4469+
4470+
if(m_strstorage.find("@") != string::npos)
4471+
{
4472+
m_strstorage = m_strstorage.substr(0, m_strstorage.find("@"));
4473+
}
4474+
else if(m_strstorage.find("sha256") != string::npos)
4475+
{
4476+
m_strstorage = e.substr(e.find(":") + 1);
4477+
}
4478+
m_strstorage = trim(m_strstorage);
44654479
RETURN_EXTRACT_STRING(m_strstorage);
44664480
}
44674481
}

0 commit comments

Comments
 (0)