Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 committed Jul 29, 2020
1 parent 2394566 commit d3f9042
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ interface DetectionsMetric {

const isElasticRule = (tags: string[]) => tags.includes(`${INTERNAL_IMMUTABLE_KEY}:true`);

/**
* Default detection rule usage count
*/
export const initialRulesUsage: DetectionRulesUsage = {
custom: {
enabled: 0,
Expand All @@ -34,6 +37,9 @@ export const initialRulesUsage: DetectionRulesUsage = {
},
};

/**
* Default ml job usage count
*/
export const initialMlJobsUsage: MlJobsUsage = {
custom: {
enabled: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const getEndpointTelemetryFromFleet = async (
try {
const { attributes: metadataAttributes } = endpointAgents[i];
const { last_checkin: lastCheckin, local_metadata: localMetadata } = metadataAttributes;
const { host, os, elastic } = localMetadata as AgentLocalMetadata; // AgentMetadata is just an empty blob, casting for our use case
const { host, os, elastic } = localMetadata as AgentLocalMetadata;

if (!uniqueHostIds.has(host.id)) {
uniqueHostIds.add(host.id);
Expand All @@ -244,10 +244,13 @@ export const getEndpointTelemetryFromFleet = async (
policyTracker = updateEndpointPolicyTelemetry(latestEndpointEvent, policyTracker);
}
}
throw new Error('I broke!');
}
} catch (error) {
// continue with the loop if any unexpected errors happen
// We will not get policy specifics or 24 hour activity for this iteration of the loop
console.log("ERROR: ", error); // eslint-disable-line
// All errors thrown in the loop would be handled here
// Not logging any errors to avoid leaking any potential PII
// Depending on when the error is thrown in the loop some specifics may be missing, but it allows the loop to continue
}
}

Expand Down

0 comments on commit d3f9042

Please sign in to comment.