summaryrefslogtreecommitdiffstats
path: root/ui/imports/api/scans
diff options
context:
space:
mode:
Diffstat (limited to 'ui/imports/api/scans')
-rw-r--r--ui/imports/api/scans/methods.js55
-rw-r--r--ui/imports/api/scans/scans.js159
-rw-r--r--ui/imports/api/scans/server/methods.js44
-rw-r--r--ui/imports/api/scans/server/publications.js82
4 files changed, 0 insertions, 340 deletions
diff --git a/ui/imports/api/scans/methods.js b/ui/imports/api/scans/methods.js
deleted file mode 100644
index 82af820..0000000
--- a/ui/imports/api/scans/methods.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
-// /
-// All rights reserved. This program and the accompanying materials /
-// are made available under the terms of the Apache License, Version 2.0 /
-// which accompanies this distribution, and is available at /
-// http://www.apache.org/licenses/LICENSE-2.0 /
-/////////////////////////////////////////////////////////////////////////////////////////
-import { ValidatedMethod } from 'meteor/mdg:validated-method';
-import * as R from 'ramda';
-
-import { Scans } from './scans';
-
-export const insert = new ValidatedMethod({
- name: 'scans.insert',
- validate: Scans.simpleSchema()
- .pick([
- 'environment',
- 'object_id',
- 'log_level',
- 'clear',
- 'loglevel',
- 'scan_only_inventory',
- 'scan_only_links',
- 'scan_only_cliques',
- ]).validator({ clean: true, filter: false }),
- run({
- environment,
- object_id,
- log_level,
- clear,
- loglevel,
- scan_only_inventory,
- scan_only_links,
- scan_only_cliques,
- }) {
- let scan = Scans.schema.clean({
- status: 'pending'
- });
- scan = R.merge(scan, {
- environment,
- object_id,
- log_level,
- clear,
- loglevel,
- scan_only_inventory,
- scan_only_links,
- scan_only_cliques,
- submit_timestamp: Date.now()
- });
-
- Scans.insert(scan);
- },
-
-});
diff --git a/ui/imports/api/scans/scans.js b/ui/imports/api/scans/scans.js
deleted file mode 100644
index 857c2ea..0000000
--- a/ui/imports/api/scans/scans.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
-// /
-// All rights reserved. This program and the accompanying materials /
-// are made available under the terms of the Apache License, Version 2.0 /
-// which accompanies this distribution, and is available at /
-// http://www.apache.org/licenses/LICENSE-2.0 /
-/////////////////////////////////////////////////////////////////////////////////////////
-import { Mongo } from 'meteor/mongo';
-import { SimpleSchema } from 'meteor/aldeed:simple-schema';
-import * as R from 'ramda';
-
-import { Constants } from '/imports/api/constants/constants';
-import { StatusesInOperation } from '/imports/api/constants/data/scans-statuses';
-
-export const Scans = new Mongo.Collection('scans', { idGeneration: 'MONGO' });
-
-Scans.schemaRelated = {
- environment: {
- label: 'Environment',
- description: 'Name of environment to scan',
- disabled: true,
- },
- status: {
- label: 'Status',
- description: 'Scan lifecycle status',
- subtype: 'select',
- options: 'scans_statuses',
- disabled: true,
- },
- object_id: {
- label: 'Scan specific object',
- description: 'Object ID',
- },
- log_level: {
- label: 'Log level',
- description: 'logging level',
- subtype: 'select',
- options: 'log_levels',
- },
- clear: {
- label: 'Clear data',
- description: 'clear all data prior to scanning',
- },
- scan_only_inventory: {
- label: 'Scan only inventory',
- description: 'do only scan to inventory',
- },
- scan_only_links: {
- label: 'Scan only links',
- description: 'do only links creation',
- },
- scan_only_cliques: {
- label: 'Scan only cliques',
- description: 'do only cliques creation',
- },
-};
-
-Scans.scansOnlyFields = ['scan_only_inventory', 'scan_only_links', 'scan_only_cliques'];
-
-let schema = {
- _id: { type: { _str: { type: String, regEx: SimpleSchema.RegEx.Id } } },
- environment: {
- type: String
- },
- status: {
- type: String,
- defaultValue: 'draft',
- custom: function () {
- let that = this;
- let statuses = Constants.findOne({ name: 'scans_statuses' }).data;
-
- if (R.isNil(R.find(R.propEq('value', that.value), statuses))) {
- return 'notAllowed';
- }
- },
- },
- object_id: {
- type: String,
- optional: true,
- },
- log_level: {
- type: String,
- defaultValue: 'warning',
- custom: function () {
- let that = this;
- let logLevels = Constants.findOne({ name: 'log_levels' }).data;
-
- if (R.isNil(R.find(R.propEq('value', that.value), logLevels))) {
- return 'notAllowed';
- }
- },
- },
- clear: {
- type: Boolean,
- defaultValue: true,
- },
- scan_only_inventory: {
- type: Boolean,
- defaultValue: false,
- },
- scan_only_links: {
- type: Boolean,
- defaultValue: false,
- },
- scan_only_cliques: {
- type: Boolean,
- defaultValue: false,
- },
- submit_timestamp: {
- type: Date,
- defaultValue: null
- },
-
-};
-
-Scans.schema = new SimpleSchema(schema);
-Scans.schema.addValidator(function () {
- let that = this;
- let env = that.field('environment').value;
-
- let currentScansCount = Scans.find({
- environment: env,
- status: { $in: StatusesInOperation }
- }).count();
-
- if (currentScansCount > 0) {
- throw {
- isError: true,
- type: 'notUinque',
- data: [],
- message: 'There is already a scan in progress.'
- };
- }
-
- let scanOnlyFields = R.filter( f => that.field(f).value, Scans.scansOnlyFields);
-
- if(scanOnlyFields.length > 1) {
- throw {
- isError: true,
- type: 'conflict',
- data: scanOnlyFields,
- message: 'Only one of the scan only fields can be selected'
- };
- }
-
-});
-
-Scans.attachSchema(Scans.schema);
-
-Scans.schemaRelated = R.mapObjIndexed((relatedItem, key) => {
- return R.merge(relatedItem, {
- type: schema[key].type
- });
-
-}, Scans.schemaRelated);
-
-export const subsScansEnvPageAmountSorted = 'scans?env*&page&amount&sortField&sortDirection';
-export const subsScansEnvPageAmountSortedCounter = `${subsScansEnvPageAmountSorted}!counter`;
diff --git a/ui/imports/api/scans/server/methods.js b/ui/imports/api/scans/server/methods.js
deleted file mode 100644
index 0fe43c2..0000000
--- a/ui/imports/api/scans/server/methods.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
-// /
-// All rights reserved. This program and the accompanying materials /
-// are made available under the terms of the Apache License, Version 2.0 /
-// which accompanies this distribution, and is available at /
-// http://www.apache.org/licenses/LICENSE-2.0 /
-/////////////////////////////////////////////////////////////////////////////////////////
-import { check } from 'meteor/check';
-import * as R from 'ramda';
-import { Scans } from '../scans';
-import { Environments } from '/imports/api/environments/environments';
-
-Meteor.methods({
- 'scansFind?start-timestamp-before': function (startTimestamp) {
- console.log('method server: scanFind?start-timestamp-before',
- R.toString(startTimestamp));
-
- check(startTimestamp, Date);
- this.unblock();
-
- let query = { start_timestamp: { $lt: startTimestamp }};
- let scan = Scans.findOne(query, {
- sort: { start_timestamp: -1 }
- });
-
- let environment = R.ifElse(
- R.isNil,
- R.always(null),
- (scan) => {
- console.log('finding environment:', scan.environment);
- let env = Environments.findOne({ name: scan.environment });
- console.log('found env:', env);
- return env;
- })(scan);
-
- console.log('found scan', scan);
-
- return {
- environment: environment,
- scan: scan,
- };
- },
-});
diff --git a/ui/imports/api/scans/server/publications.js b/ui/imports/api/scans/server/publications.js
deleted file mode 100644
index 774fe3d..0000000
--- a/ui/imports/api/scans/server/publications.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
-// /
-// All rights reserved. This program and the accompanying materials /
-// are made available under the terms of the Apache License, Version 2.0 /
-// which accompanies this distribution, and is available at /
-// http://www.apache.org/licenses/LICENSE-2.0 /
-/////////////////////////////////////////////////////////////////////////////////////////
-import { Meteor } from 'meteor/meteor';
-import * as R from 'ramda';
-import { Counts } from 'meteor/tmeasday:publish-counts';
-
-import { Scans,
- subsScansEnvPageAmountSorted,
- subsScansEnvPageAmountSortedCounter,
-} from '../scans.js';
-
-Meteor.publish('scans?env', function (env_name) {
- console.log('server subscribtion: scans?env');
- console.log(env_name);
-
- return Scans.find({
- environment: env_name,
- });
-});
-
-Meteor.publish('scans?env*', function (env) {
- console.log('server subscribtion: scans?env*');
- console.log(env);
-
- //let that = this;
-
- let query = {};
- if (! R.isNil(env)) { query = R.assoc('environment', env, query); }
- console.log('-query: ', query);
- return Scans.find(query);
-});
-
-Meteor.publish(subsScansEnvPageAmountSorted, function (
- env, page, amountPerPage, sortField, sortDirection) {
-
- console.log(`server subscribtion: ${subsScansEnvPageAmountSorted}`);
- console.log(env);
- console.log('page: ', page);
- console.log('amount: ', amountPerPage);
- console.log('sortField: ', sortField, R.isNil(sortField));
- console.log('sortDirection: ', sortDirection);
-
- let skip = (page - 1) * amountPerPage;
-
- let query = {};
- if (! R.isNil(env)) { query = R.assoc('environment', env, query); }
- console.log('-query: ', query);
- let sortParams = {};
-
- sortParams = R.ifElse(R.isNil, R.always(sortParams),
- R.assoc(R.__, sortDirection, sortParams))(sortField);
-
- console.log('sort params:', sortParams);
-
- let qParams = {
- limit: amountPerPage,
- skip: skip,
- sort: sortParams,
- };
-
- Counts.publish(this, subsScansEnvPageAmountSortedCounter, Scans.find(query), {
- noReady: true
- });
-
- return Scans.find(query, qParams);
-});
-
-Meteor.publish('scans?id', function (id) {
- console.log('server subscribtion: scans?id');
- console.log('-id: ', id);
-
- //let that = this;
-
- let query = { _id: id };
- return Scans.find(query);
-});