Skip to content

Commit

Permalink
Migrate hyades frontend features (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahibamittal authored Feb 26, 2024
1 parent 4bd8ff0 commit a34247f
Show file tree
Hide file tree
Showing 11 changed files with 630 additions and 16 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@coreui/icons": "0.4.1",
"@coreui/vue": "2.1.2",
"@johmun/vue-tags-input": "2.1.0",
"@monaco-editor/loader": "^1.3.3",
"axios": "1.6.0",
"bootstrap": "4.6.1",
"bootstrap-table": "1.20.2",
Expand All @@ -38,6 +39,9 @@
"jquery-treegrid": "0.3.0",
"json5": "^2.2.3",
"lodash-es": "4.17.21",
"monaco-editor": "^0.41.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"monaco-languageclient": "^6.4.6",
"oidc-client": "1.11.5",
"perfect-scrollbar": "1.5.5",
"showdown": "2.1.0",
Expand Down
18 changes: 18 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"project_vulnerabilities": "Project Vulnerabilities",
"vulnerable_components": "Vulnerable Components",
"vulnerable_dependencies": "Vulnerable Dependencies",
"score": "Score",
"inherited_risk_score": "Inherited Risk Score",
"risk_score": "Risk Score",
"vulnerable_projects": "Vulnerable Projects",
Expand All @@ -60,6 +61,7 @@
"active": "Active",
"inactive": "Inactive",
"name": "Name",
"author": "Author",
"published": "Published",
"cwe": "CWE",
"cwe_full": "Common Weakness Enumeration (CWE)",
Expand Down Expand Up @@ -90,7 +92,14 @@
"violations_audited": "Violations Audited",
"violations_unaudited": "Violations Unaudited",
"attributed_on": "Attributed On",
"published_at": "Published At",
"view_details": "View Details",
"policy_bundle_info": "Bundle Info",
"policy_bundle_url": "Bundle URL",
"policy_bundle_hash": "Bundle Hash",
"policy_bundle_sync": "Sync Bundle",
"policy_last_bundle_sync_failed": "Last bundle sync failed",
"policy_bundle_sync_timestamp": "Last Synced On",
"project_details": "Project Details",
"description": "Description",
"tags": "Tags",
Expand Down Expand Up @@ -133,6 +142,8 @@
"include_policy_violations": "Include Policy Violations",
"project_cloning_in_progress": "The project is being created with the cloning options specified",
"vulnerability": "Vulnerability",
"ratings": "Ratings",
"method": "Method",
"analysis": "Analysis",
"analysis_tooltip": "The current state of an occurrence of a vulnerability",
"justification": "Justification",
Expand All @@ -150,6 +161,7 @@
"cvss": "CVSS",
"cvss_v2": "CVSSv2",
"cvss_v3": "CVSSv3",
"vector": "Vector",
"cvss_v2_vector": "CVSSv2 Vector",
"cvss_v3_vector": "CVSSv3 Vector",
"cvss_base_score": "CVSS Base Score",
Expand Down Expand Up @@ -215,6 +227,7 @@
"will_not_fix": "Will not fix",
"rollback": "Rollback",
"workaround_available": "Workaround available",
"vendor_response": "Vendor Response",
"response": "Vendor Response (project)",
"response_tooltip": "A response to the vulnerability by the manufacturer, supplier, or project responsible for the affected component or service",
"analysis_details_tooltip": "Details (explanation, workaround details, and other impact information)",
Expand Down Expand Up @@ -244,6 +257,7 @@
"project_reanalyze": "Reanalyze",
"project_reanalyze_tooltip": "Runs configured analyzers to detect vulnerabilities in this project's components. Will use any cached results that haven't expired yet",
"project_reanalyze_requested": "A Project Vulnerability Analysis has been requested. Project vulnerability data will be updated when the reanalysis task has completed.",
"policy_bundle_sync_requested": "Policy bundle synchronization requested. Vulnerability policy data will be updated when the sync is completed.",
"vex_uploaded": "VEX uploaded",
"reset": "Reset",
"bom_uploaded": "BOM uploaded",
Expand Down Expand Up @@ -353,14 +367,18 @@
"vulnerability_updated": "Vulnerability updated",
"vulnerability_deleted": "Vulnerability deleted",
"created": "Created",
"validFrom": "Valid From",
"validUntil": "Valid Until",
"internal": "Internal",
"latest_version": "Latest Version",
"integrity": "Integrity",
"metric_refresh_requested": "A refresh has been requested. Metrics will be updated when the refresh task has completed.",
"used_by": "Used By",
"oidc_availability_check_failed": "Failed to determine availability of OpenID Connect",
"oidc_redirect_failed": "An error occurred while redirecting to the OpenID Connect identity provider",
"policies": "Policies",
"license_groups": "License Groups",
"vulnerability_policies": "Vulnerability Policies",
"create_policy": "Create Policy",
"policy_created": "Policy created",
"delete_policy": "Delete Policy",
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function configRoutes() {
{
path: 'policy',
name: 'Policy Management',
alias: ['policy/policies', 'policy/licenseGroups'],
alias: ['policy/policies', 'policy/licenseGroups', 'policy/vulnerability'],
component: PolicyManagement,
meta: {
title: i18n.t('message.policy_management'),
Expand Down
4 changes: 3 additions & 1 deletion src/shared/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@
"URL_ACL_MAPPING": "api/v1/acl/mapping",
"URL_ACL_TEAM": "api/v1/acl/team",
"URL_VEX": "api/v1/vex",
"URL_OSV_ECOSYSTEM": "api/v1/integration/osv/ecosystem"
"URL_OSV_ECOSYSTEM": "api/v1/integration/osv/ecosystem",
"URL_VULNERABILITY_POLICY": "api/v1/policy/vulnerability",
"URL_WORKFLOW": "api/v1/workflow"
}
79 changes: 79 additions & 0 deletions src/views/components/MonacoEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<div ref="monaco-editor" style="border: 1px solid #52525e; border-radius: 0.25rem; height: 100px;"></div>
</template>

<script>
import loader from "@monaco-editor/loader";
export default {
name: "MonacoEditor",
props: {
value: String,
readOnly: Boolean,
markers: [],
},
data() {
return {
monaco: null,
editor: null,
editorModel: null,
}
},
mounted() {
loader.init().then(monaco => {
this.monaco = monaco;
this.editor = monaco.editor.create(this.$refs["monaco-editor"], {
automaticLayout: true,
bracketPairColorization: true,
cursorBlinking: 'phase',
language: "python",
lineDecorationsWidth: 0,
matchBrackets: true,
minimap: {
enabled: false,
},
lineNumbersMinChars: 3,
overviewRulerLanes: 0,
scrollBeyondLastLine: false,
theme: "vs-dark",
wordWrap: "on",
wrappingStrategy: "advanced",
readOnly: this.readOnly
});
this.editorModel = this.editor.getModel();
this.editorModel.onDidChangeContent(this.handleContentChange);
this.editorModel.setValue(this.value ? this.value : '');
});
},
beforeDestroy() {
if (this.editor) {
this.editorModel.dispose();
this.editor.dispose();
this.editor = null;
this.editorModel = null;
}
},
methods: {
handleContentChange: function (event) {
this.monaco.editor.removeAllMarkers("foo");
this.$emit("change", this.editor.getValue(), event);
this.$emit("input", this.editor.getValue());
},
},
watch: {
value() {
if (this.editor && this.value !== this.editor.getValue()) {
this.editorModel.setValue(this.value);
}
},
markers() {
if (!this.markers) {
this.monaco.editor.removeAllMarkers("foo");
}
this.monaco.editor.setModelMarkers(this.editorModel, "foo", this.markers);
}
}
}
</script>
87 changes: 87 additions & 0 deletions src/views/policy/PolicyBundleInfoModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<b-modal id="policyBundleInfoModal" size="lg" hide-header-close no-stacking :title="$t('message.policy_bundle_info')">
<b-tabs class="body-bg-color" style="border:0;padding:0">
<b-tab class="body-bg-color" style="border:0;padding:0" active>
<template v-slot:title><i class="fa fa-edit"></i> {{ $t('message.general') }}</template>
<b-card>
<b-input-group-form-input id="bundle-url" input-group-size="mb-3" type="text" v-model="bundleInfo.url"
lazy="true" feedback="false" autofocus="true"
:label="$t('message.policy_bundle_url')" disabled="true" />
<b-input-group-form-input id="bundle-hash" input-group-size="mb-3" type="text" v-model="bundleInfo.hash"
lazy="true" feedback="false" autofocus="false"
:label="$t('message.policy_bundle_hash')" disabled="true" />
<b-input-group-form-input id="bundle-created" input-group-size="mb-3" type="text" :value="bundleCreated"
lazy="true" feedback="false" autofocus="false"
:label="$t('message.created')" disabled="true" />
<b-input-group-form-input id="bundle-last-sync" :value="bundleLastSynced" feedback="false"
:label="$t('message.policy_bundle_sync_timestamp')" disabled="true" />
</b-card>
</b-tab>
</b-tabs>
<template v-slot:modal-footer="{ cancel }">
<b-button size="md" variant="secondary" @click="cancel()">{{ $t('message.close') }}</b-button>
</template>
</b-modal>
</template>

<script>
import BInputGroupFormInput from "../../forms/BInputGroupFormInput";
import BInputGroupFormSelect from "../../forms/BInputGroupFormSelect";
import { Switch as cSwitch } from '@coreui/vue';
import permissionsMixin from "../../mixins/permissionsMixin";
import Multiselect from "vue-multiselect"
import VueTagsInput from '@johmun/vue-tags-input';
import common from "../../shared/common";
export default {
name: "PolicyBundleInfoModal",
mixins: [permissionsMixin],
components: {
BInputGroupFormInput,
VueTagsInput,
BInputGroupFormSelect,
cSwitch,
Multiselect
},
props: {
bundleInfo: Object,
},
data() {
return {
syncToken: {}
}
},
computed: {
bundleCreated: {
get() {
return (typeof this.bundleInfo.created !== 'undefined' && this.bundleInfo.created != null) ? common.formatTimestamp(this.bundleInfo.created) : "-";
}
},
bundleLastSynced: {
get() {
return typeof (this.bundleInfo.lastSuccessfulSync != null && this.bundleInfo.lastSuccessfulSync === "number")
? common.formatTimestamp(this.bundleInfo.lastSuccessfulSync, true)
: "-";
}
}
}
}
</script>

<style lang="scss">
@import "../../assets/scss/vendors/vue-tags-input/vue-tags-input";
</style>

<style scoped>
.tab-content .tab-pane{
padding: 0 !important;
}
.tab-content {
border: 0 !important;
}
.card {
border:0;
padding:0;
margin-bottom:0;
}
</style>
Loading

0 comments on commit a34247f

Please sign in to comment.