mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Add policies to the standard query library on fleetdm.com (#2939)
* setting query purpose using kind * updated query library sort * change query purpose section, add resolution section * Update query-library.ejs * remove policies from standard query library, updated commented out policy resolution checks * Update query-library.page.js
This commit is contained in:
parent
59e01fbe08
commit
0cca889dd3
@ -6,7 +6,7 @@ parasails.registerPage('query-library', {
|
||||
inputTextValue: '',
|
||||
inputTimers: {},
|
||||
searchString: '', // The user input string to be searched against the query library
|
||||
selectedPurpose: 'all queries', // Initially set to all, the user may select a different option to filter queries by purpose (e.g., "all queries", "information", "detection")
|
||||
selectedKind: 'all queries', // Initially set to all, the user may select a different option to filter queries by purpose (e.g., "all queries", "informational", "policies")
|
||||
selectedPlatform: 'all platforms', // Initially set to all, the user may select a different option to filter queries by platform (e.g., "all platforms", "macOS", "Windows", "Linux")
|
||||
},
|
||||
|
||||
@ -15,7 +15,7 @@ parasails.registerPage('query-library', {
|
||||
return this.queries.filter(
|
||||
(query) =>
|
||||
this._isIncluded(query.platforms, this.selectedPlatform) &&
|
||||
this._isIncluded(query.purpose, this.selectedPurpose)
|
||||
this._isIncluded(query.kind, this.selectedKind)
|
||||
);
|
||||
},
|
||||
|
||||
@ -42,8 +42,8 @@ parasails.registerPage('query-library', {
|
||||
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
|
||||
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
|
||||
methods: {
|
||||
clickSelectPurpose(purpose) {
|
||||
this.selectedPurpose = purpose;
|
||||
clickSelectKind(kind) {
|
||||
this.selectedKind = kind;
|
||||
},
|
||||
|
||||
clickSelectPlatform(platform) {
|
||||
|
19
website/scripts/build-static-content.js
vendored
19
website/scripts/build-static-content.js
vendored
@ -28,18 +28,19 @@ module.exports = {
|
||||
let RELATIVE_PATH_TO_QUERY_LIBRARY_YML_IN_FLEET_REPO = 'docs/01-Using-Fleet/standard-query-library/standard-query-library.yml';
|
||||
let yaml = await sails.helpers.fs.read(path.join(topLvlRepoPath, RELATIVE_PATH_TO_QUERY_LIBRARY_YML_IN_FLEET_REPO)).intercept('doesNotExist', (err)=>new Error(`Could not find standard query library YAML file at "${RELATIVE_PATH_TO_QUERY_LIBRARY_YML_IN_FLEET_REPO}". Was it accidentally moved? Raw error: `+err.message));
|
||||
|
||||
let queriesWithProblematicRemediations = [];
|
||||
let queriesWithProblematicResolutions = [];
|
||||
let queriesWithProblematicContributors = [];
|
||||
let queries = YAML.parseAllDocuments(yaml).map((yamlDocument)=>{
|
||||
let query = yamlDocument.toJSON().spec;
|
||||
query.kind = yamlDocument.toJSON().kind;
|
||||
query.slug = _.kebabCase(query.name);// « unique slug to use for routing to this query's detail page
|
||||
if (false) {
|
||||
// if ((query.remediation !== undefined && !_.isString(query.remediation)) || (query.purpose !== 'Detection' && _.isString(query.remediation))) { TODO: maybe bring this back later
|
||||
// console.log(typeof query.remediation);
|
||||
queriesWithProblematicRemediations.push(query);
|
||||
// } else if (query.remediation === undefined) {
|
||||
} else { // « For now set remediation to N/A for all queries until we reinstate checks that are commented out above. TODO: finish that
|
||||
query.remediation = 'N/A';// « We set this to a string here so that the data type is always string. We use N/A so folks can see there's no remediation and contribute if desired.
|
||||
// if ((query.resolution !== undefined && !_.isString(query.resolution)) || (query.kind !== 'policy' && _.isString(query.resolution))) { TODO: maybe bring this back later
|
||||
// console.log(typeof query.resolution);
|
||||
queriesWithProblematicResolutions.push(query);
|
||||
// } else if (query.resolution === undefined) {
|
||||
} else { // « For now set resolution to N/A for all queries until we reinstate checks that are commented out above. TODO: finish that
|
||||
query.resolution = 'N/A';// « We set this to a string here so that the data type is always string. We use N/A so folks can see there's no remediation and contribute if desired.
|
||||
}
|
||||
|
||||
// GitHub usernames may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.
|
||||
@ -50,8 +51,8 @@ module.exports = {
|
||||
return query;
|
||||
});
|
||||
// Report any errors that were detected along the way in one fell swoop to avoid endless resubmitting of PRs.
|
||||
if (queriesWithProblematicRemediations.length >= 1) {
|
||||
throw new Error('Failed parsing YAML for query library: The "remediation" of a query should either be absent (undefined) or a single string (not a list of strings). And "remediation" should only be present when a query\'s purpose is "Detection". But one or more queries have an invalid "remediation": ' + _.pluck(queriesWithProblematicRemediations, 'slug').sort());
|
||||
if (queriesWithProblematicResolutions.length >= 1) {
|
||||
throw new Error('Failed parsing YAML for query library: The "resolution" of a query should either be absent (undefined) or a single string (not a list of strings). And "resolution" should only be present when a query\'s kind is "policy". But one or more queries have an invalid "resolution": ' + _.pluck(queriesWithProblematicResolutions, 'slug').sort());
|
||||
}//•
|
||||
// Assert uniqueness of slugs.
|
||||
if (queries.length !== _.uniq(_.pluck(queries, 'slug')).length) {
|
||||
|
10
website/views/pages/query-detail.ejs
vendored
10
website/views/pages/query-detail.ejs
vendored
@ -22,10 +22,10 @@
|
||||
<h3 class="pb-4 mb-3 m-0">Query</h3>
|
||||
<code class="pb-3">{{query.query ? query.query : '--'}}</code>
|
||||
</div>
|
||||
<!-- <div purpose="remediation" v-if="query.purpose === 'Detection' && query.remediation">
|
||||
<h3 class="pt-5 pb-3">Remediation</h3>
|
||||
<p>{{query.remediation ? query.remediation : 'N/A'}}</p>
|
||||
</div> -->
|
||||
<div purpose="resolution" v-if="query.kind === 'policy' && query.resolution">
|
||||
<h3 class="pt-5 pb-3">Resolve</h3>
|
||||
<p>{{query.resolution}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div purpose="summary-sidebar" class="col-md-4 order-first order-md-last p-0 pl-md-3 pt-md-4">
|
||||
@ -44,7 +44,7 @@
|
||||
<div class="border-top py-2">
|
||||
<div class="d-flex flex-md-column justify-content-between justify-content-md-start align-items-center align-items-md-start py-1 py-md-3">
|
||||
<h5 class="pb-md-2 m-0">Purpose</h5>
|
||||
<p class="m-0">{{query.purpose ? query.purpose : '--'}}</p>
|
||||
<p class="m-0">{{query.kind === 'policy' ? 'Policy' : query.kind === 'query' ? 'Informational' : '--'}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-top py-2 pb-md-4">
|
||||
|
16
website/views/pages/query-library.ejs
vendored
16
website/views/pages/query-library.ejs
vendored
@ -19,10 +19,10 @@
|
||||
</div>
|
||||
<div class="d-flex select-mobile">
|
||||
<div class="select-mobile-border">
|
||||
<select class="select-purpose mobile font-weight-bold" v-model="selectedPurpose">
|
||||
<select class="select-purpose mobile font-weight-bold" v-model="selectedKind">
|
||||
<option value="all queries" selected>All queries</option>
|
||||
<option value="informational">Informational queries</option>
|
||||
<option value="policies">Policies</option>
|
||||
<option value="query">Informational queries</option>
|
||||
<option value="policy">Policies</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -46,15 +46,15 @@
|
||||
<p class="d-inline-flex mb-0 pr-1">Show</p>
|
||||
<button class="btn btn-secondary btn-sm dropdown-toggle p-0" type="button"
|
||||
id="dropdownMenuSelectPurpose" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{selectedPurpose}}
|
||||
{{ selectedKind === 'query' ? 'informational' : selectedKind === 'policy' ? 'policies' : 'all queries'}}
|
||||
</button>
|
||||
<div class="dropdown-menu p-2" aria-labelledby="dropdownMenuSelectPurpose">
|
||||
<button class="dropdown-item" type="button" @click="clickSelectPurpose('all queries')">all
|
||||
queries</button>
|
||||
<button class="dropdown-item" type="button"
|
||||
@click="clickSelectPurpose('informational')">informational</button>
|
||||
@click="clickSelectKind('all queries')">all queries</button>
|
||||
<button class="dropdown-item" type="button"
|
||||
@click="clickSelectKind('query')">informational</button>
|
||||
<button class="dropdown-item" type="button"
|
||||
@click="clickSelectPurpose('policies')">policies</button>
|
||||
@click="clickSelectKind('policy')">policies</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user