Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 2 #10

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ db/tirdb.sqlite-journal

# internal test
test
server/api/localtest
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARG BASE_CONTAINER
FROM $BASE_CONTAINER
USER node
WORKDIR /src
COPY --chown=node:node . .
RUN npm run build
RUN npm prune -production
19 changes: 11 additions & 8 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a section to this to make it clearer that you need to read the license/notice files.

Also should add like an authors section or something to clearly attribute work done by both the mitre and lm teams

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

TIR is a web application to dynamically manage compliance data for a system.

Tir is a Armenian god of wisdom and the namesake of the TIR (Test Ingest Respository). TIR will help manage a system's STIG/SRG/SCTM content from a myriad of test tool formats.
Tir is a Armenian god of wisdom and the namesake of the TIR (Test Ingest Respository). TIR will help manage a system's STIG/SRG/SCTM content from a myriad of test tool formats.

## Features

* Group system compliance data
* Store STIG results files and their hsitory for a system .
* Store Quarterly DISA STIG libraries.
* Streamline Quarterly STIG Update Process
* Import automated test tool results
* Export compliance data
- Group system compliance data
- Store STIG results files and their hsitory for a system .
- Store Quarterly DISA STIG libraries.
- Streamline Quarterly STIG Update Process
- Import automated test tool results
- Export compliance data

## Dev Setup

Expand All @@ -22,6 +22,7 @@ Tir is a Armenian god of wisdom and the namesake of the TIR (Test Ingest Resposi
- node v18+

### Clone repo

```bash
git clone <cloneurl>
cd tir
Expand All @@ -33,15 +34,17 @@ cd tir
npm install
```


#### `.env` for SQLite config

```ini
SQLITE=true
JWT_KEY= //Required: Key that TIR will use for JWT
SECRET_KEY= //Required
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an explanation for what this field should be.

We should probably add a .env-example file or something similar.

INIT_PASSWORD= //Required: Initial Password for initial TIR admin Account
```

#### `.env` for Postgres config

```ini
PORT= //Optional: Dev Web Server Port Defaults to 3000
DATABASE_HOST= //Required: Postgres Database IP/FQDN
Expand Down
5 changes: 5 additions & 0 deletions cert_loc/cert_response.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was an accidental commit of this file. Providing an example file or response is fine, but this feels like it was something used for testing.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"result": "Success",
"filename": "good.tar",
"error": false
}
465 changes: 265 additions & 200 deletions components/BoundaryItems.vue

Large diffs are not rendered by default.

100 changes: 55 additions & 45 deletions components/CompanyList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
{{ get[0].name }}
</h4>
<h4 v-else class="mt-4 text-xl font-bold tracking-tight text-gray-800 dark:text-white sm:text-2xl">
Companies
{{ tierView.alias }}
</h4>
<h4 class="mt-1 text-lg text-gray-800 dark:text-white">
Select your company to view relevant {{ inflection.pluralize(boundaryView.alias) }}.
</h4>
<h4 class="mt-1 text-lg text-gray-800 dark:text-white">Select your company to view relevant boundaries.</h4>
</div>

<div v-show="currentUser.UserRole.name === 'User'" class="mt-4 sm:ml-16 sm:mt-0 sm:flex-none">
<button
type="button"
class="inline-flex items-center gap-x-1.5 rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
@click="open = true"
@click="[(open = true), (edit = false), (companyName = null)]"
>
<PlusIcon class="-ml-0.5 h-5 w-5 rounded-md bg-indigo-500" aria-hidden="true" />
Company
Expand All @@ -28,7 +30,7 @@
v-if="tierList.length === 0"
type="button"
class="ml-3 inline-flex items-center gap-x-1.5 rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
@click="[editCompany(), router.push('/boundaries/' + get[0].name + 'id' + get[0].id)]"
@click="[editCompany()]"
>
<PlusIcon class="-ml-0.5 h-5 w-5 rounded-md bg-indigo-500" aria-hidden="true" />
Boundary
Expand Down Expand Up @@ -257,7 +259,7 @@
<DialogPanel class="pointer-events-auto w-screen max-w-xs">
<form
class="flex h-full flex-col divide-y divide-gray-200 bg-white shadow-xl dark:bg-gray-800"
@submit.prevent="edit ? '' : addCompany(companyData)"
@submit.prevent="edit ? '' : addCompany()"
>
<div class="h-0 flex-1 overflow-y-auto">
<div class="bg-indigo-700 px-4 py-6 sm:px-6">
Expand All @@ -282,7 +284,9 @@
</div>
<div class="mt-1">
<p v-if="edit" class="text-sm text-indigo-300">Edit your company and save changes.</p>
<p v-else class="text-sm text-indigo-300">Add your company to start creating boundaries.</p>
<p v-else class="text-sm text-indigo-300">
Add your company to start creating {{ inflection.pluralize(boundaryView.alias) }}
</p>
</div>
</div>
<div class="flex flex-1 flex-col justify-between">
Expand Down Expand Up @@ -404,6 +408,7 @@
</button>
<button
v-else
@click="[(open = false)]"
type="submit"
class="ml-4 inline-flex justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
Expand Down Expand Up @@ -460,6 +465,7 @@ import { XMarkIcon, ExclamationTriangleIcon, ChevronUpDownIcon } from "@heroicon

import { storeToRefs } from "pinia";
import { useBreadcrumbStore } from "~~/stores/Breadcrumb";
import inflection from "inflection";
const showErrorNotification = ref(false);
const errorMsg = ref();
const errorName = ref("");
Expand Down Expand Up @@ -496,36 +502,40 @@ const companyDetails = {
// const tierList = ref()
// const get = ref();

//for the term alias
const { data: currentAlias } = await useFetch("/api/boundaries/alias");
//renders the current alias
const tierView = ref(currentAlias.value[0]);
// const tierViewAliasPlural = inflection.pluralize(boundaryView.alias);
const boundaryView = ref(currentAlias.value[1]);
// const boundaryViewAliasPlural = inflection.pluralize(boundaryView.alias);

const { data: tierList, error } = await useFetch("/api/tiers/list", {
method: "POST",
body: companyList,
key: "tierListAPI",
});

async function checkTier(id, hasBoundaries, companyName, parentId) {
const { data: tierCheck, error: listError } = await useFetch("/api/tiers/list", {
method: "POST",
body: { parentId: id },
});
try {
await $fetch("/api/tiers/list", {
method: "POST",
body: { parentId: id },
});

const { data: getCheck, error: getError } = await useFetch("/api/tiers/get", {
method: "POST",
body: { id },
});
await $fetch("/api/tiers/get", {
method: "POST",
body: { id },
});

if (listError.value === null && getError.value === null) {
uniqueCompany(id, companyName, parentId);
if (hasBoundaries) {
router.push("/boundaries/" + companyName + "id" + id);
} else {
tierId.value = id;
}
} else {
if (listError.value !== null) {
errorMsg.value = listError.value.statusMessage;
} else {
errorMsg.value = getError.value.statusMessage;
}
} catch (error) {
errorMsg.value = error.data.statusMessage;

showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
Expand All @@ -540,20 +550,22 @@ const { data: get } = await useFetch("/api/tiers/get", {
pages.value.length = pagePosition(tierId.value) + 1;
/// //////////////////////////////////
const { data: currentUser } = await useFetch("/api/auth/currentUser");
const companyData = {
name: companyName,
parentId: tierId,
ownerId: currentUser.value.id,
};

async function addCompany(companyData) {
async function addCompany() {
try {
await useFetch("/api/tiers/create", {
await $fetch("/api/tiers/create", {
method: "POST",
body: companyData,
body: {
name: companyName.value,
parentId: tierId.value,
ownerId: currentUser.value.id,
},
});
} finally {
location.reload();
} catch (err) {
errorMsg.value = err.data.statusMessage;
showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
}
}
/// /////////////////////////////////
Expand All @@ -562,23 +574,20 @@ async function addCompany(companyData) {
const editId = ref();
async function updateEditDetails() {
const editCompanyPkg = {
id: editId,
name: editCompanyName,
id: editId.value,
name: editCompanyName.value,
ownerId: selectedPerson.value.id,
};
try {
const { error } = await useFetch("/api/tiers/edit", {
await $fetch("/api/tiers/edit", {
method: "PUT",
body: editCompanyPkg,
watch: false,
});
if (error.value != null) {
errorMsg.value = error.value.statusMessage;
showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
} else {
console.log("Good");
}
} catch (error) {
errorMsg.value = error.data.statusMessage;
showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
} finally {
refreshNuxtData("tierListAPI");
}
Expand All @@ -590,12 +599,15 @@ async function editCompany() {
hasBoundaries: true,
};
try {
await useFetch("/api/tiers/edit", {
await $fetch("/api/tiers/edit", {
method: "PUT",
body: companyEdit,
});
} finally {
// location.reload()
router.push("/boundaries/" + get.value[0].name + "id" + get.value[0].id);
} catch (err) {
errorMsg.value = err.data.statusMessage;
showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
}
}
/// ////////////////////////////////////
Expand All @@ -611,8 +623,6 @@ async function removeCompany(companyId) {
errorMsg.value = error.value.statusMessage;
showErrorNotification.value = true;
setTimeout(() => (showErrorNotification.value = false), 6000);
} else {
console.log("Good");
}
} finally {
refreshNuxtData("tierListAPI");
Expand Down
37 changes: 20 additions & 17 deletions components/DashBoardItems.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
<template>
<div class="bg-white dark:bg-gray-800 py-24 rounded-lg">
<div class="rounded-lg bg-white py-24 dark:bg-gray-800">
<div class="mx-auto max-w-7xl px-6 lg:px-8">
<div class="mx-auto max-w-2xl lg:mx-0">
<h2 class="text-3xl font-bold tracking-tight text-gray-800 dark:text-white sm:text-4xl">Test Ingest Repository.
<h2 class="text-3xl font-bold tracking-tight text-gray-800 dark:text-white sm:text-4xl">
Test Ingest Repository.
</h2>
<p class="mt-2 text-lg leading-8 text-gray-600 dark:text-gray-400">TIR is a central repository to maintain your
boundary's
security
posture.</p>
<h4 class="mt-12 text-xl font-bold tracking-tight text-gray-800 dark:text-white sm:text-2xl">See Your Updates
Below</h4>
<p class="mt-2 text-lg leading-8 text-gray-600 dark:text-gray-400">
TIR is a central repository to maintain your
{{ inflection.pluralize(boundaryView.alias.toLowerCase()) }} security posture.
</p>
<h4 class="mt-12 text-xl font-bold tracking-tight text-gray-800 dark:text-white sm:text-2xl">
See Your Updates Below
</h4>
</div>
<div
class="mx-auto mt-5 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-16 border-t border-gray-500 pt-10 sm:pt-16 lg:mx-0 lg:max-w-none lg:grid-cols-3">
class="mx-auto mt-5 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-16 border-t border-gray-500 pt-10 sm:pt-16 lg:mx-0 lg:max-w-none lg:grid-cols-3"
>
<article>
<h1 class="text-lg text-gray-800 dark:text-white font-bold">Boundary Changes</h1>
<h1 class="text-lg font-bold text-gray-800 dark:text-white">{{ boundaryView.alias }} Changes</h1>
<div class="flex max-w-xl flex-col items-start justify-between">
<DashBoarditemsBoundaryChanges />
</div>

</article>
<article>
<h1 class="text-lg text-gray-800 dark:text-white font-bold">New Libraries Imported</h1>
<h1 class="text-lg font-bold text-gray-800 dark:text-white">New Libraries Imported</h1>
<div class="flex max-w-xl flex-col items-start justify-between">
<DashBoarditemsNewLibraries />
</div>

</article>

<article>
<h1 class="text-lg text-gray-800 dark:text-white font-bold">Upcoming Dates</h1>
<h1 class="text-lg font-bold text-gray-800 dark:text-white">Upcoming Dates</h1>
<div class="flex max-w-xl flex-col items-start justify-between">
<DashBoarditemsDates />
</div>

</article>
</div>
</div>
</div>
</template>

<script setup>
import inflection from "inflection";

</script>
const { data: currentAlias } = await useFetch("/api/boundaries/alias");
const boundaryView = ref(currentAlias.value[1]);
</script>
Loading