UNPKG

fabric8-analytics-dependency-editor-jyas

Version:
146 lines 5.36 kB
import { Component, Input } from '@angular/core'; import { ErrorUIModel } from '../model/data.model'; import { DependencyEditorService } from '../shared/dependency-editor.service'; var SecurityComponent = /** @class */ (function () { function SecurityComponent(service) { var _this = this; this.service = service; this.isLoading = true; this.title = 'Security Alert'; this.icon = 'fa fa-shield'; this.noOfCves = null; this.hasIssue = false; this.toHave = false; this.secureIssue = false; this.itSecurity = true; this.cveName = []; this.alertConfig = null; this.config = {}; this.tooltipText = 'Shows the security vulnerabilities in the stack'; this.isLoading = true; this.service.securitySubscription.subscribe(function (response) { if (response instanceof ErrorUIModel) { _this.config = { header: { tooltip: _this.tooltipText, icon: _this.icon, name: _this.title }, body: { defaultText: response.message } }; _this.alertConfig = _this.config; } else { var res = response; if (res['request_id'] && res['stack_highest_cvss']) { _this.formAlert(); } } _this.isLoading = false; }); this.service.needsSecurityChange.subscribe(function (response) { if (response) { _this.getCveData(); } }); } SecurityComponent.prototype.ngOnChanges = function () { this.formAlert(); }; SecurityComponent.prototype.ngOnInit = function () { this.formAlert(); }; SecurityComponent.prototype.formAlert = function () { var _this = this; this.hasIssue = false; this.secureIssue = false; this.cveName = []; if (this.cveData) { this.noOfCves = 0; var count_1 = -1; this.itSecurity = true; this.cveData.result.forEach(function (item) { count_1++; if (item.cve) { _this.noOfCves++; _this.hasIssue = true; _this.secureIssue = true; if (item.cve !== null) { _this.cveName.push({ isAccordion: false, primaryText: item.cve.details && item.cve.details.length > 0 ? item.cve.details[0].cve_id : '', secondaryText: item.package }); } } }); if (this.noOfCves > 0) { this.itSecurity = false; } this.config = { header: { icon: this.icon, tooltip: this.tooltipText, name: this.title, countInfo: this.noOfCves, indicator: this.itSecurity === false ? 'ERROR' : '' }, body: { normal: this.cveName, defaultText: this.noOfCves === 0 ? 'The analytics engine has not identified any security issues affecting your stack.' : '' } }; } else { this.noOfCves = null; this.config = { header: { tooltip: this.tooltipText, icon: this.icon, name: this.title }, body: { defaultText: 'The analytics engine has not identified any security issues affecting your stack.' } }; } this.alertConfig = this.config; this.isLoading = false; }; SecurityComponent.prototype.getShow = function (event) { this.toHave = event.toShow; }; SecurityComponent.prototype.getCveData = function () { var _this = this; var payload = this.service.getPayload(); this.isLoading = true; this.service.getDependencyData('CVE', payload) .subscribe(function (response) { _this.service.securitySubscription.next(response); _this.isLoading = false; }, function (error) { _this.cveData = null; _this.service.securitySubscription.next(new ErrorUIModel(error.status, error.message)); _this.isLoading = false; }); }; SecurityComponent.decorators = [ { type: Component, args: [{ selector: 'app-security', styles: [require('./security.component.css').toString()], template: require('./security.component.html') },] }, ]; /** @nocollapse */ SecurityComponent.ctorParameters = function () { return [ { type: DependencyEditorService, }, ]; }; SecurityComponent.propDecorators = { 'boosterInfo': [{ type: Input },], }; return SecurityComponent; }()); export { SecurityComponent }; //# sourceMappingURL=security.component.js.map