Skip to content

Commit

Permalink
fix handling of container metadata in "infra" events [SMAGENT-1647] (#…
Browse files Browse the repository at this point in the history
…1418)

* fix handling of container metadata in "infra" events.

* address review comments.
look for "sha256" instead.
  • Loading branch information
anoop-sysd authored May 24, 2019
1 parent a6ab1e6 commit baf311c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions userspace/libsinsp/filterchecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4442,12 +4442,16 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
vector<string> subelements = sinsp_split(e, ':');
ASSERT(subelements.size() == 2);
m_strstorage = trim(subelements[1]);
if(m_strstorage.length() > 12)
{
m_strstorage = m_strstorage.substr(0, 12);
}
RETURN_EXTRACT_STRING(m_strstorage);
}
}
else if(m_field_id == TYPE_INFRA_DOCKER_CONTAINER_NAME)
{
if(e.substr(0, sizeof("Name") - 1) == "Name")
if(e.substr(0, sizeof("name") - 1) == "name")
{
vector<string> subelements = sinsp_split(e, ':');
ASSERT(subelements.size() == 2);
Expand All @@ -4461,7 +4465,17 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
{
vector<string> subelements = sinsp_split(e, ':');
ASSERT(subelements.size() == 2);
m_strstorage = trim(subelements[1]);
m_strstorage = subelements[1];

if(m_strstorage.find("@") != string::npos)
{
m_strstorage = m_strstorage.substr(0, m_strstorage.find("@"));
}
else if(m_strstorage.find("sha256") != string::npos)
{
m_strstorage = e.substr(e.find(":") + 1);
}
m_strstorage = trim(m_strstorage);
RETURN_EXTRACT_STRING(m_strstorage);
}
}
Expand Down

0 comments on commit baf311c

Please sign in to comment.