Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOGL-7274: Asset Tracker not able to cope with assets that include sp… #911

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions C/common/management_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ bool ManagementClient::addAssetTrackingTuple(const std::string& service,
try {
convert << "{ \"service\" : \"" << JSONescape(service) << "\", ";
convert << " \"plugin\" : \"" << plugin << "\", ";
convert << " \"asset\" : \"" << asset << "\", ";
convert << " \"asset\" : \"" << JSONescape(asset) << "\", ";
convert << " \"event\" : \"" << event << "\" }";

auto res = this->getHttpClient()->request("POST", "/fledge/track", convert.str());
Expand Down Expand Up @@ -1756,7 +1756,7 @@ bool ManagementClient::addStorageAssetTrackingTuple(const std::string& service,
try {
convert << "{ \"service\" : \"" << JSONescape(service) << "\", ";
convert << " \"plugin\" : \"" << plugin << "\", ";
convert << " \"asset\" : \"" << asset << "\", ";
convert << " \"asset\" : \"" << JSONescape(asset) << "\", ";
convert << " \"event\" : \"" << event << "\", ";
convert << " \"deprecated\" :\"" << deprecated << "\", ";
convert << " \"data\" : { \"datapoints\" : \[ \"" << d << "\" ], ";
Expand Down
8 changes: 4 additions & 4 deletions C/services/south/ingest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int Ingest::createStatsDbEntry(const string& assetName)

// SELECT * FROM fledge.statiatics WHERE key = statistics_key
const Condition conditionKey(Equals);
Where *wKey = new Where("key", conditionKey, statistics_key);
Where *wKey = new Where("key", conditionKey, JSONescape(statistics_key));
Query qKey(wKey);

ResultSet* result = 0;
Expand All @@ -75,8 +75,8 @@ int Ingest::createStatsDbEntry(const string& assetName)
{
// Prepare insert values for insertTable
InsertValues newStatsEntry;
newStatsEntry.push_back(InsertValue("key", statistics_key));
newStatsEntry.push_back(InsertValue("description", string("Readings received from asset ")+assetName));
newStatsEntry.push_back(InsertValue("key", JSONescape(statistics_key)));
newStatsEntry.push_back(InsertValue("description", string("Readings received from asset ")+JSONescape(assetName)));
// Set "value" field for insert using the JSON document object
newStatsEntry.push_back(InsertValue("value", 0));
newStatsEntry.push_back(InsertValue("previous_value", 0));
Expand Down Expand Up @@ -181,7 +181,7 @@ void Ingest::updateStats()
for (auto & c: key) c = toupper(c);

// Prepare "WHERE key = name
Where *wPluginStat = new Where("key", conditionStat, key);
Where *wPluginStat = new Where("key", conditionStat, JSONescape(key));

// Prepare value = value + inc
ExpressionValues *updateValue = new ExpressionValues;
Expand Down