SUrvey now works

This commit is contained in:
2024-11-17 19:41:30 +01:00
parent 51b0641702
commit e75de81e39
13 changed files with 1210 additions and 201 deletions

View File

@@ -0,0 +1,96 @@
package controllers
import (
"html/template"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"risklet/db"
)
func Advanced(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
handleAdvancedGet(w, r)
} else if r.Method == "POST" {
handleAdvancedPost(w, r)
} else {
http.Error(w, "Method not allowed.", http.StatusMethodNotAllowed)
return
}
}
func handleAdvancedPost(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
log.Println("Error processing form: ", err)
handleAdvancedGet(w, r)
}
company := createCompany(r.PostForm)
companyId, err := db.InsertCompany(company)
if err != nil {
log.Println("Error inserting company into database ", err)
handleAdvancedGet(w, r)
}
advancedProfile := createAdvancedProfile(companyId, r.PostForm)
_, err = db.InsertAdvancedProfile(advancedProfile)
if err != nil {
log.Println("Error inserting into database ", err)
handleAdvancedGet(w, r)
}
}
func handleAdvancedGet(w http.ResponseWriter, r *http.Request) {
companyId := r.PathValue("companyId")
lp := filepath.Join("application", "layouts", "main.html")
fp := filepath.Join("application", "views", "advanced.html")
log.Println("Hitting Advanced")
// Return a 404 if the template doesn't exist
info, err := os.Stat(fp)
if err != nil {
if os.IsNotExist(err) {
http.NotFound(w, r)
return
}
}
// Return a 404 if the request is for a directory
if info.IsDir() {
http.NotFound(w, r)
return
}
tmpl, err := template.ParseFiles(lp, fp)
if err != nil {
// Log the detailed error
log.Print(err.Error())
// Return a generic "Internal Server Error" message
http.Error(w, http.StatusText(500), 500)
return
}
err = tmpl.ExecuteTemplate(w, "main.html", companyId)
if err != nil {
log.Print(err.Error())
http.Error(w, http.StatusText(500), 500)
}
}
func createAdvancedProfile(companyId int, f url.Values) db.AdvancedProfile {
return db.AdvancedProfile{
CompanyId: companyId,
GeographicDistribution: f.Get("GeographicDistribution"),
CustomerConcentration: f.Get("CustomerConcentration"),
ProductServicePortfolio: f.Get("ProductServicePortfolio"),
OrganizationalCulture: f.Get("OrganizationalCulture"),
SupplierDiversity: f.Get("SupplierDiversity"),
TechnologicalInfrastructure: f.Get("TechnologicalInfrastructure"),
IntellectualProperty: f.Get("IntellectualProperty"),
ManagementTeamExperience: f.Get("ManagementTeamExperience"),
}
}

View File

@@ -41,13 +41,15 @@ func handlePost(w http.ResponseWriter, r *http.Request) {
handleGet(w, r)
}
http.Redirect(w, r, "/thankyou", http.StatusSeeOther)
}
func handleGet(w http.ResponseWriter, r *http.Request) {
lp := filepath.Join("application", "layouts", "main.html")
fp := filepath.Join("application", "views", "signup.html")
log.Println("Hitting Signup")
// add a CSP header to allow only same-origin scripts
w.Header().Set("Content-Security-Policy", "script-src 'unsafe-eval' 'self'")
// Return a 404 if the template doesn't exist
info, err := os.Stat(fp)

View File

@@ -4,8 +4,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello, World!</title>
<!-- Bootstrap CSS -->
<link href="/static/css/bootstrap.css" rel="stylesheet">
<link href="/static/css/Jost.css" rel="stylesheet">
<link href="/static/css/main.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-dark bg-dark navbar-expand-lg text-light">
@@ -32,8 +33,10 @@
</div>
</div>
</nav>
<article class="px-3">
{{block "content" .}} {{end}}
<!-- Bootstrap JS and dependencies -->
</article>
<script src="/static/js/bootstrap.js"></script>
{{block "bottom" .}} {{end}}
</body>

View File

@@ -9,5 +9,6 @@ func SetupAppServer() {
fs := http.FileServer(http.Dir("./application/static"))
http.Handle("GET /static/", http.StripPrefix("/static/", fs))
http.HandleFunc("/signup/", controllers.Signup)
http.HandleFunc("/advanced/{companyString}", controllers.Advanced)
http.HandleFunc("/", controllers.Index)
}

View File

@@ -0,0 +1,4 @@
body {
font-family: 'Jost', sans-serif;
}

View File

@@ -0,0 +1,164 @@
document.addEventListener('DOMContentLoaded', (event) => {
const form = document.querySelector('form');
const formElements = form.elements;
// Load saved form state
/* loadFormState(formElements);
// Save form state on change
form.addEventListener('change', () => {
saveFormState(formElements);
}); */
setUpNavigation()
});
function nextQuestion() {
document.currentQuestion++;
hideNavElementsAndQuestions();
showQuestion(`q${document.currentQuestion}`);
setButtonVisiblity('back', true);
setButtonVisiblity('next', true);
if (document.currentQuestion === document.lastQuestion) {
setButtonVisiblity('next', false);
setButtonVisiblity('submit', true);
}
setNextButtonAvailability();
}
function previousQuestion() {
if (document.currentQuestion > 0) {
document.currentQuestion--;
hideNavElementsAndQuestions();
showQuestion(`q${document.currentQuestion}`);
setButtonVisiblity('next', true);
setButtonVisiblity('submit', false);
document.nextEnabled = true;
}
setButtonVisiblity('back', document.currentQuestion !== 0);
setNextButtonAvailability();
}
function setUpNavigation() {
const questions = document.querySelectorAll('.question');
document.currentQuestion = 0;
document.nextEnabled = false;
document.lastQuestion = questions.length - 1;
hideNavElementsAndQuestions();
showQuestion(`q${document.currentQuestion}`);
setButtonVisiblity('next', true);
const nextButton = document.getElementById('next');
const backButton = document.getElementById('back');
nextButton.addEventListener('click', nextQuestion);
backButton.addEventListener('click', previousQuestion);
setNextButtonAvailability();
// check if next button should be enabled on every input, checkbox and radio button bellow class of .question change
const inputs = document.querySelectorAll('.question input, .question select, .question textarea');
inputs.forEach(input => {
input.addEventListener('change', setNextButtonAvailability);
});
}
function setNextButtonAvailability() {
console.log('Setting next button availability');
// check if current question is answered
// and then enable the next button, disable it otherwise
const currentQuestion = document.getElementById(`q${document.currentQuestion}`);
const nextButton = document.getElementById('next');
const submitButton = document.getElementById('submit');
// check if any input in the current question is checked, or filled in case it is a text input
let nextEnabled = false;
const inputs = currentQuestion.querySelectorAll('input, select, textarea');
for (let input of inputs) {
// if the input is not visible, skip it
if (input.checkVisibility() === false) {
continue;
}
if (input.type === 'checkbox' || input.type === 'radio') {
if (input.checked) {
nextEnabled = true;
break;
}
} else {
if (input.value) {
nextEnabled = true;
break;
}
}
}
nextButton.disabled = !nextEnabled;
submitButton.disabled = !nextEnabled;
}
function saveFormState(elements) {
const formState = {};
for (let element of elements) {
if (element.name) {
if (element.type === 'select-multiple') {
formState[element.name] = Array.from(element.selectedOptions).map(option => option.value);
} else if (element.type === 'checkbox' || element.type === 'radio') {
formState[element.name] = element.checked ? element.value : formState[element.name] || null;
} else {
formState[element.name] = element.value;
}
}
}
localStorage.setItem('formState', JSON.stringify(formState));
}
function loadFormState(elements) {
const formState = JSON.parse(localStorage.getItem('formState'));
if (formState) {
for (let element of elements) {
if (element.name && formState[element.name] !== undefined) {
if (element.type === 'select-multiple') {
Array.from(element.options).forEach(option => {
option.selected = formState[element.name].includes(option.value);
});
} else if (element.type === 'checkbox' || element.type === 'radio') {
element.checked = formState[element.name] === element.value;
} else {
element.value = formState[element.name];
}
}
}
}
}
function hideNavElementsAndQuestions() {
const questions = document.querySelectorAll('.question');
questions.forEach(question => {
// add bootstrap hidden class to the element
question.classList.add('d-none');
});
const nextButton = document.getElementById('next');
const backButton = document.getElementById('back');
const submitButton = document.getElementById('submit');
nextButton.classList.add('d-none');
backButton.classList.add('d-none');
submitButton.classList.add('d-none');
}
function showQuestion(questionId) {
const question = document.getElementById(questionId);
question.classList.remove('d-none');
}
function setButtonVisiblity(buttonId, visible) {
const button = document.getElementById(buttonId);
if (visible) {
button.classList.remove('d-none');
} else {
button.classList.add('d-none');
}
}

View File

@@ -1,44 +0,0 @@
document.addEventListener('DOMContentLoaded', (event) => {
const form = document.querySelector('form');
const formElements = form.elements;
// Load saved form state
loadFormState(formElements);
// Save form state on change
form.addEventListener('change', () => {
saveFormState(formElements);
});
});
function saveFormState(elements) {
const formState = {};
for (let element of elements) {
if (element.name) {
if (element.type === 'select-multiple') {
formState[element.name] = Array.from(element.selectedOptions).map(option => option.value);
} else {
formState[element.name] = element.value;
}
}
}
localStorage.setItem('formState', JSON.stringify(formState));
}
function loadFormState(elements) {
const formState = JSON.parse(localStorage.getItem('formState'));
if (formState) {
for (let element of elements) {
if (element.name && formState[element.name]) {
if (element.type === 'select-multiple') {
Array.from(element.options).forEach(option => {
option.selected = formState[element.name].includes(option.value);
});
} else {
element.value = formState[element.name];
}
}
}
}
}

View File

@@ -0,0 +1,198 @@
{{define "content"}}
<div class="container">
<div class="row">
<div class="col">
<h1 class="pt-4 mt-5 mb-4">Advanced Risk Assessment</h1>
<hr>
<form method="post">
<!-- Geographic Operational Scope -->
<div class="mb-3 question" id="q1">
<label for="geo-scope" class="form-label mt-3">What is your organization's geographic operational scope?</label>
<hr>
<select class="form-select" id="geo-scope" name="GeoScope" required>
<option value="single-country">Single country</option>
<option value="single-region">Multiple countries - Single region</option>
<option value="multiple-regions">Multiple countries - Multiple regions</option>
<option value="global">Global operations</option>
</select>
<small class="form-text text-muted py-3">Determines exposure to different cybersecurity regulations.</small>
</div>
<!-- Customer Base Distribution -->
<div class="mb-3 question" id="q2">
<label for="customer-base" class="form-label mt-3">How would you characterize your customer base distribution?</label>
<hr>
<select class="form-select" id="customer-base" name="CustomerBase" required>
<option value="few-key">Few key clients (1-5)</option>
<option value="moderate">Moderate concentration (6-20)</option>
<option value="diverse">Diverse customer base (20+)</option>
</select>
<small class="form-text text-muted py-3">Assesses potential impact of data breaches.</small>
</div>
<!-- Primary Customer Type -->
<div class="mb-3 question" id="q3">
<label for="customer-type" class="form-label mt-3">What is your primary customer type?</label>
<hr>
<select class="form-select" id="customer-type" name="CustomerType" required>
<option value="b2b">Primarily B2B</option>
<option value="b2c">Primarily B2C</option>
<option value="mixed">Mixed B2B/B2C</option>
</select>
<small class="form-text text-muted py-3">Defines data protection requirements.</small>
</div>
<!-- Product/Service Portfolio -->
<div class="mb-3 question" id="q4">
<label for="product-portfolio" class="form-label mt-3">How diversified is your product/service portfolio?</label>
<hr>
<select class="form-select" id="product-portfolio" name="ProductPortfolio" required>
<option value="single">Single product/service</option>
<option value="2-5">2-5 products/services</option>
<option value="more-than-5">More than 5 products/services</option>
</select>
<small class="form-text text-muted py-3">Indicates the variety of systems requiring protection.</small>
</div>
<!-- Supplier Base Structure -->
<div class="mb-3 question" id="q5">
<label for="supplier-base" class="form-label mt-3">What is your supplier base structure?</label>
<hr>
<select class="form-select" id="supplier-base" name="SupplierBase" required>
<option value="single-critical">Single/few critical suppliers</option>
<option value="moderate">Moderate supplier base</option>
<option value="highly-diverse">Highly diverse supplier base</option>
</select>
<small class="form-text text-muted py-3">Assesses third-party cybersecurity risks.</small>
</div>
<!-- IT Infrastructure Model -->
<div class="mb-3 question" id="q6">
<label class="form-label mt-3">What is your primary IT infrastructure model?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-on-prem" value="on-premises">
<label class="form-check-label" for="it-on-prem">On-premises systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-cloud" value="cloud-based">
<label class="form-check-label" for="it-cloud">Cloud-based systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-hybrid" value="hybrid">
<label class="form-check-label" for="it-hybrid">Hybrid infrastructure</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-legacy" value="legacy">
<label class="form-check-label" for="it-legacy">Legacy systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-modern" value="modern">
<label class="form-check-label" for="it-modern">Modern architecture</label>
</div>
</div>
<small class="form-text text-muted py-3">Determines specific cybersecurity controls.</small>
</div>
<!-- Intellectual Property Protection -->
<div class="mb-3 question" id="q7">
<label class="form-label mt-3">How does your organization protect and manage intellectual property?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-patents" value="patents">
<label class="form-check-label" for="ip-patents">Patents owned</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-licensed" value="licensed-ip">
<label class="form-check-label" for="ip-licensed">Licensed IP from others</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-trade-secrets" value="trade-secrets">
<label class="form-check-label" for="ip-trade-secrets">Trade secrets</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-joint" value="joint-ip">
<label class="form-check-label" for="ip-joint">Joint IP ownership</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-none" value="no-ip">
<label class="form-check-label" for="ip-none">No significant IP</label>
</div>
</div>
<small class="form-text text-muted py-3">Evaluates cybersecurity needs based on IP ownership.</small>
</div>
<!-- Sensitive Data -->
<div class="mb-3 question" id="q8">
<label class="form-label mt-3">What type of sensitive data does your organization handle?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-personal" value="personal">
<label class="form-check-label" for="data-personal">Personal customer data</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-financial" value="financial">
<label class="form-check-label" for="data-financial">Financial records</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-healthcare" value="healthcare">
<label class="form-check-label" for="data-healthcare">Healthcare information</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-ip" value="ip">
<label class="form-check-label" for="data-ip">Intellectual property</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-gov" value="government">
<label class="form-check-label" for="data-gov">Government data</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-payment" value="payment">
<label class="form-check-label" for="data-payment">Payment card data</label>
</div>
</div>
<small class="form-text text-muted py-3">Identifies required compliance frameworks.</small>
</div>
<!-- Critical Business Systems -->
<div class="mb-3 question" id="q9">
<label for="integration-level" class="form-label mt-3">How integrated are your critical business systems?</label>
<hr>
<select class="form-select" id="integration-level" name="IntegrationLevel" required>
<option value="fully-integrated">Fully integrated</option>
<option value="partially-integrated">Partially integrated</option>
<option value="mostly-separate">Mostly separate</option>
<option value="completely-isolated">Completely isolated</option>
</select>
<small class="form-text text-muted py-3">Evaluates potential for cascade failures.</small>
</div>
<!-- Remote Work Policy -->
<div class="mb-3 question" id="q10">
<label for="remote-policy" class="form-label mt-3">What is your organization's remote work policy?</label>
<hr>
<select class="form-select" id="remote-policy" name="RemotePolicy" required>
<option value="no-remote">No remote work allowed</option>
<option value="limited-remote">Limited remote work options</option>
<option value="hybrid">Hybrid work model</option>
<option value="fully-remote">Fully remote operations available</option>
</select>
<small class="form-text text-muted py-3">Determines the scope of remote access security requirements.</small>
</div>
<div class="d-flex justify-content-end mt-4">
<button type="button" class="btn btn-lg btn-outline-secondary me-3" id="back">Back</button>
<button type="submit" class="btn btn-primary btn-lg" id="submit">Next</button>
</div>
</form>
</div>
</div>
</div>
{{end}}
{{define "bottom"}}
<script src="/static/js/formHandling.js"></script>
{{end}}

View File

@@ -2,74 +2,180 @@
<div class="container">
<div class="row">
<div class="col">
<h1 class="mt-5 mb-3">Sign Up</h1>
<h1 class="pt-4 mt-5 mb-4">Risk Assessment Questions</h1>
<hr>
<form method="post">
<div class="mb-3">
<label for="name" class="form-label">Organization Name</label>
<!-- Organization Name -->
<div class="mb-3 question" id="q0">
<label for="name" class="form-label mt-3">What is the name of your organization?</label>
<hr>
<input type="text" class="form-control" id="name" name="Name" required>
<small class="form-text text-muted">Name of the Organization that will appear in the report.</small>
<small class="form-text text-muted py-3">Name of the Organization that will appear in the
report.</small>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<!-- Email -->
<div class="mb-3 question" id="q1">
<label for="email" class="form-label mt-3">What is your email?</label>
<hr>
<input type="email" class="form-control" id="email" name="Email" required>
<small class="form-text text-muted">Email of the person responsible for using Risklet. Report and magic link for log in will be sent to this email. </small>
<small class="form-text text-muted py-3">Email of the person responsible for using Risklet. Report
and
magic link for login will be sent to this email.</small>
</div>
<!-- Employee Headcount -->
<div class="mb-3">
<label for="employees" class="form-label">What is your organization's current employee headcount?</label>
<select class="form-select" id="employees" name="Employees" required>
<option value="1-10">1-10</option>
<option value="11-100">11-100</option>
<option value="101-10000">101-10,000</option>
<option value="10001-">10,001+</option>
</select>
<small class="form-text text-muted">Helps determine the scale of IT infrastructure and security needs based on user volume.</small>
<div class="mb-3 question" id="q2">
<label class="form-label mt-3">What is your organization's current employee headcount?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Employees" id="employees-1-10"
value="1-10" required>
<label class="form-check-label" for="employees-1-10">1-10</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Employees" id="employees-11-100"
value="11-100">
<label class="form-check-label" for="employees-11-100">11-100</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Employees" id="employees-101-10000"
value="101-10000">
<label class="form-check-label" for="employees-101-10000">101-10,000</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Employees" id="employees-10001"
value="10001-">
<label class="form-check-label" for="employees-10001">10,001+</label>
</div>
</div>
<small class="form-text text-muted py-3">Helps determine the scale of IT infrastructure and security
needs based on user volume.</small>
</div>
<!-- Annual Revenue -->
<div class="mb-3">
<label for="revenue" class="form-label">What is your organization's annual revenue range?</label>
<select class="form-select" id="revenue" name="Revenue" required>
<option value="under-1m">$ under 1M</option>
<option value="1m-100m">$ 1M-100M</option>
<option value="100m-1b">$ 100M-1B</option>
<option value="above-1b">$ Above 1B</option>
</select>
<small class="form-text text-muted">Indicates available resources for cybersecurity investments and helps assess risk appetite.</small>
<div class="mb-3 question" id="q3">
<label class="form-label mt-3">What is your organization's annual revenue range?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Revenue" id="revenue-under-1m"
value="under-1m" required>
<label class="form-check-label" for="revenue-under-1m">$ under 1M</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Revenue" id="revenue-1m-100m"
value="1m-100m">
<label class="form-check-label" for="revenue-1m-100m">$ 1M-100M</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Revenue" id="revenue-100m-1b"
value="100m-1b">
<label class="form-check-label" for="revenue-100m-1b">$ 100M-1B</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Revenue" id="revenue-above-1b"
value="above-1b">
<label class="form-check-label" for="revenue-above-1b">$ Above 1B</label>
</div>
</div>
<small class="form-text text-muted py-3">Indicates available resources for cybersecurity investments
and
helps assess risk appetite.</small>
</div>
<!-- Critical Business Applications -->
<div class="mb-3">
<label for="business-apps" class="form-label">How many critical business applications do your employees use daily?</label>
<select class="form-select" id="business-apps" name="Applications" required>
<option value="1-5">1-5</option>
<option value="5-20">5-20</option>
<option value="more-than-20">More than 20</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Reveals the complexity of your technology landscape and potential attack surface.</small>
<div class="mb-3 question" id="q4">
<label class="form-label mt-3">How many critical business applications do your employees use
daily?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Applications" id="apps-1-5" value="1-5"
required>
<label class="form-check-label" for="apps-1-5">1-5</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Applications" id="apps-5-20"
value="5-20">
<label class="form-check-label" for="apps-5-20">5-20</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Applications" id="apps-more-than-20"
value="more-than-20">
<label class="form-check-label" for="apps-more-than-20">More than 20</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Applications" id="apps-unknown"
value="unknown">
<label class="form-check-label" for="apps-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Reveals the complexity of your technology landscape and
potential attack surface.</small>
</div>
<!-- Regulatory Frameworks -->
<div class="mb-3">
<label for="compliance" class="form-label">Which regulatory frameworks is your organization required to comply with?</label>
<select class="form-select" id="compliance" name="Compliance" multiple required>
<option value="gdpr">GDPR</option>
<option value="hipaa">HIPAA</option>
<option value="pci-dss">PCI DSS</option>
<option value="sox">SOX</option>
<option value="iso-27001">ISO 27001</option>
<option value="ccpa">CCPA</option>
<option value="nist">NIST</option>
<option value="other">Other</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Identifies mandatory security controls and compliance requirements that must be implemented.</small>
<div class="mb-3 question" id="q5">
<label class="form-label mt-3">Which regulatory frameworks is your organization required to comply
with?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-gdpr"
value="gdpr">
<label class="form-check-label" for="compliance-gdpr">GDPR</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-hipaa"
value="hipaa">
<label class="form-check-label" for="compliance-hipaa">HIPAA</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-pci-dss"
value="pci-dss">
<label class="form-check-label" for="compliance-pci-dss">PCI DSS</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-sox"
value="sox">
<label class="form-check-label" for="compliance-sox">SOX</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-iso-27001"
value="iso-27001">
<label class="form-check-label" for="compliance-iso-27001">ISO 27001</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-ccpa"
value="ccpa">
<label class="form-check-label" for="compliance-ccpa">CCPA</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-nist"
value="nist">
<label class="form-check-label" for="compliance-nist">NIST</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-other"
value="other">
<label class="form-check-label" for="compliance-other">Other</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="Compliance" id="compliance-unknown"
value="unknown">
<label class="form-check-label" for="compliance-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Identifies mandatory security controls and compliance
requirements that must be implemented.</small>
</div>
<!-- Industry Sector -->
<div class="mb-3">
<label for="industry" class="form-label">What is your primary industry sector?</label>
<div class="mb-3 question" id="q6">
<label for="industry" class="form-label mt-3">What is your primary industry sector?</label>
<hr>
<select class="form-select" id="industry" name="Industry" required>
<option value="agriculture">Agriculture, food and forestry</option>
<option value="energy">Energy and mining</option>
@@ -92,85 +198,505 @@
<option value="public-service">Public service</option>
<option value="utilities">Utilities (water; gas; electricity)</option>
<option value="shipping">Shipping; ports; fisheries; inland waterways</option>
<option value="transport">Transport (including civil aviation; railways; road transport)</option>
<option value="transport">Transport (including civil aviation; railways; road transport)
</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Determines industry-specific threats, regulations, and security best practices applicable to your business.</small>
<small class="form-text text-muted py-3">Determines industry-specific threats, regulations, and
security
best practices applicable to your business.</small>
</div>
<!-- IT Dependency -->
<div class="mb-3">
<label for="it-dependency" class="form-label">On a scale from 1-10, how dependent is your business operations on technology?</label>
<input type="range" class="form-range" id="it-dependency" name="ITDependency" min="1" max="10" required>
<div class="mb-3 question" id="q7">
<label for="it-dependency" class="form-label mt-3">On a scale from 1-10, how dependent is your
business
operations on technology?</label>
<hr>
<input type="range" class="form-range" id="it-dependency" name="ITDependency" min="1" max="10"
required>
<div class="d-flex justify-content-between">
<span>Not dependent at all</span>
<span>Heavily dependent</span>
</div>
<small class="form-text text-muted">Measures the potential business impact of IT disruptions and helps prioritize security investments.</small>
<small class="form-text text-muted py-3">Measures the potential business impact of IT disruptions
and
helps prioritize security investments.</small>
</div>
<!-- Sensitive Data Level -->
<div class="mb-3">
<label for="data-sensitivity" class="form-label">What level of sensitive data does your organization process?</label>
<select class="form-select" id="data-sensitivity" name="DataSensitivity" required>
<option value="public">Public</option>
<option value="internal">Internal</option>
<option value="sensitive">Sensitive</option>
<option value="confidential">Confidential</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Assesses the potential impact of data breaches and determines required security controls.</small>
<div class="mb-3 question" id="q8">
<label class="form-label mt-3">What level of sensitive data does your organization process?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="DataSensitivity" id="data-public"
value="public" required>
<label class="form-check-label" for="data-public">Public</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="DataSensitivity" id="data-internal"
value="internal">
<label class="form-check-label" for="data-internal">Internal</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="DataSensitivity" id="data-sensitive"
value="sensitive">
<label class="form-check-label" for="data-sensitive">Sensitive</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="DataSensitivity" id="data-confidential"
value="confidential">
<label class="form-check-label" for="data-confidential">Confidential</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="DataSensitivity" id="data-unknown"
value="unknown">
<label class="form-check-label" for="data-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Assesses the potential impact of data breaches and
determines
required security controls.</small>
</div>
<!-- Network Infrastructure Model -->
<div class="mb-3">
<label for="network-architecture" class="form-label">What best describes your organization's network infrastructure model?</label>
<select class="form-select" id="network-architecture" name="NetworkSegmentation" required>
<option value="flat">Flat network</option>
<option value="some-segmentation">Some segmentation</option>
<option value="segmented">Segmented network</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Helps understand the complexity and vulnerability points in your technical environment.</small>
<div class="mb-3 question" id="q9">
<label class="form-label mt-3">What best describes your organization's network infrastructure
model?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="NetworkSegmentation" id="network-flat"
value="flat" required>
<label class="form-check-label" for="network-flat">Flat network</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="NetworkSegmentation" id="network-some"
value="some-segmentation">
<label class="form-check-label" for="network-some">Some segmentation</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="NetworkSegmentation"
id="network-segmented" value="segmented">
<label class="form-check-label" for="network-segmented">Segmented network</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="NetworkSegmentation" id="network-unknown"
value="unknown">
<label class="form-check-label" for="network-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Helps understand the complexity and vulnerability points in
your
technical environment.</small>
</div>
<!-- Remote Workforce Percentage -->
<div class="mb-3">
<label for="remote-work" class="form-label">What percentage of your workforce operates remotely?</label>
<select class="form-select" id="remote-work" name="RemoteWork" required>
<option value="none">None</option>
<option value="1-10">1-10%</option>
<option value="above-10">Above 10%</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Evaluates remote access security requirements and potential exposure to external threats.</small>
<div class="mb-3 question" id="q10">
<label class="form-label mt-3">What percentage of your workforce operates remotely?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemoteWork" id="remote-none" value="none"
required>
<label class="form-check-label" for="remote-none">None</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemoteWork" id="remote-1-10"
value="1-10">
<label class="form-check-label" for="remote-1-10">1-10%</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemoteWork" id="remote-above-10"
value="above-10">
<label class="form-check-label" for="remote-above-10">Above 10%</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemoteWork" id="remote-unknown"
value="unknown">
<label class="form-check-label" for="remote-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Evaluates remote access security requirements and potential
exposure to external threats.</small>
</div>
<!-- Third-Party Vendor Access -->
<div class="mb-3">
<label for="third-party" class="form-label">How many third-party vendors have access to your systems?</label>
<select class="form-select" id="third-party" name="VendorAccess" required>
<option value="none">None</option>
<option value="1-5">1-5</option>
<option value="more-than-5">More than 5</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Assesses supply chain risk and the need for vendor security management.</small>
<div class="mb-3 question" id="q11">
<label class="form-label mt-3">How many third-party vendors have access to your systems?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="VendorAccess" id="vendor-none"
value="none" required>
<label class="form-check-label" for="vendor-none">None</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="VendorAccess" id="vendor-1-5"
value="1-5">
<label class="form-check-label" for="vendor-1-5">1-5</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="VendorAccess" id="vendor-more-than-5"
value="more-than-5">
<label class="form-check-label" for="vendor-more-than-5">More than 5</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="VendorAccess" id="vendor-unknown"
value="unknown">
<label class="form-check-label" for="vendor-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Assesses supply chain risk and the need for vendor security
management.</small>
</div>
<!-- Internal Software Development -->
<div class="mb-3">
<label for="internal-dev" class="form-label">What is the extent of your internal software development activities?</label>
<select class="form-select" id="internal-dev" name="InternalDev" required>
<option value="none">None</option>
<option value="some">Some internal software development</option>
<option value="significant">Significant internal software development</option>
<option value="unknown">I don't know</option>
</select>
<small class="form-text text-muted">Determines the need for secure development practices and application security measures.</small>
<div class="mb-3 question" id="q12">
<label class="form-label mt-3">What is the extent of your internal software development
activities?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InternalDev" id="dev-none" value="none"
required>
<label class="form-check-label" for="dev-none">None</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InternalDev" id="dev-some" value="some">
<label class="form-check-label" for="dev-some">Some internal software development</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InternalDev" id="dev-significant"
value="significant">
<label class="form-check-label" for="dev-significant">Significant internal software
development</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InternalDev" id="dev-unknown"
value="unknown">
<label class="form-check-label" for="dev-unknown">I don't know</label>
</div>
</div>
<small class="form-text text-muted py-3">Determines the need for secure development practices and
application security measures.</small>
</div>
<button type="submit" class="btn btn-primary">Sign Up</button>
<!-- skip rest if needed -->
<!-- Geographic Operational Scope -->
<div class="mb-3 question" id="q13">
<label class="form-label mt-3">What is your organization's geographic operational scope?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="GeoScope" id="geo-single-country"
value="single-country" required>
<label class="form-check-label" for="geo-single-country">Single country</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="GeoScope" id="geo-single-region"
value="single-region">
<label class="form-check-label" for="geo-single-region">Multiple countries - Single
region</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="GeoScope" id="geo-multiple-regions"
value="multiple-regions">
<label class="form-check-label" for="geo-multiple-regions">Multiple countries - Multiple
regions</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="GeoScope" id="geo-global" value="global">
<label class="form-check-label" for="geo-global">Global operations</label>
</div>
</div>
<small class="form-text text-muted py-3">Determines exposure to different cybersecurity
regulations.</small>
</div>
<div class="mb-3 question" id="q14">
<label class="form-label mt-3">How would you characterize your customer base distribution?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerBase" id="customer-few-key"
value="few-key" required>
<label class="form-check-label" for="customer-few-key">Few key clients (1-5)</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerBase" id="customer-moderate"
value="moderate">
<label class="form-check-label" for="customer-moderate">Moderate concentration
(6-20)</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerBase" id="customer-diverse"
value="diverse">
<label class="form-check-label" for="customer-diverse">Diverse customer base (20+)</label>
</div>
</div>
<small class="form-text text-muted py-3">Assesses potential impact of data breaches.</small>
</div>
<!-- Primary Customer Type -->
<div class="mb-3 question" id="q15">
<label class="form-label mt-3">What is your primary customer type?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerType" id="customer-b2b"
value="b2b" required>
<label class="form-check-label" for="customer-b2b">Primarily B2B</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerType" id="customer-b2c"
value="b2c">
<label class="form-check-label" for="customer-b2c">Primarily B2C</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="CustomerType" id="customer-mixed"
value="mixed">
<label class="form-check-label" for="customer-mixed">Mixed B2B/B2C</label>
</div>
</div>
<small class="form-text text-muted py-3">Defines data protection requirements.</small>
</div>
<!-- Product/Service Portfolio -->
<div class="mb-3 question" id="q16">
<label class="form-label mt-3">How diversified is your product/service portfolio?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ProductPortfolio" id="portfolio-single"
value="single" required>
<label class="form-check-label" for="portfolio-single">Single product/service</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ProductPortfolio" id="portfolio-2-5"
value="2-5">
<label class="form-check-label" for="portfolio-2-5">2-5 products/services</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ProductPortfolio"
id="portfolio-more-than-5" value="more-than-5">
<label class="form-check-label" for="portfolio-more-than-5">More than 5
products/services</label>
</div>
</div>
<small class="form-text text-muted py-3">Indicates the variety of systems requiring
protection.</small>
</div>
<!-- Supplier Base Structure -->
<div class="mb-3 question" id="q17">
<label class="form-label mt-3">What is your supplier base structure?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="SupplierBase"
id="supplier-single-critical" value="single-critical" required>
<label class="form-check-label" for="supplier-single-critical">Single/few critical
suppliers</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="SupplierBase" id="supplier-moderate"
value="moderate">
<label class="form-check-label" for="supplier-moderate">Moderate supplier base</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="SupplierBase"
id="supplier-highly-diverse" value="highly-diverse">
<label class="form-check-label" for="supplier-highly-diverse">Highly diverse supplier
base</label>
</div>
</div>
<small class="form-text text-muted py-3">Assesses third-party cybersecurity risks.</small>
</div>
<!-- IT Infrastructure Model -->
<div class="mb-3 question" id="q18">
<label class="form-label mt-3">What is your primary IT infrastructure model?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-on-prem"
value="on-premises">
<label class="form-check-label" for="it-on-prem">On-premises systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-cloud"
value="cloud-based">
<label class="form-check-label" for="it-cloud">Cloud-based systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-hybrid"
value="hybrid">
<label class="form-check-label" for="it-hybrid">Hybrid infrastructure</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-legacy"
value="legacy">
<label class="form-check-label" for="it-legacy">Legacy systems</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ITInfrastructure" id="it-modern"
value="modern">
<label class="form-check-label" for="it-modern">Modern architecture</label>
</div>
</div>
<small class="form-text text-muted py-3">Determines specific cybersecurity controls.</small>
</div>
<!-- Intellectual Property Protection -->
<div class="mb-3 question" id="q19">
<label class="form-label mt-3">How does your organization protect and manage intellectual
property?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-patents"
value="patents">
<label class="form-check-label" for="ip-patents">Patents owned</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-licensed"
value="licensed-ip">
<label class="form-check-label" for="ip-licensed">Licensed IP from others</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-trade-secrets"
value="trade-secrets">
<label class="form-check-label" for="ip-trade-secrets">Trade secrets</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-joint"
value="joint-ip">
<label class="form-check-label" for="ip-joint">Joint IP ownership</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="IPProtection" id="ip-none"
value="no-ip">
<label class="form-check-label" for="ip-none">No significant IP</label>
</div>
</div>
<small class="form-text text-muted py-3">Evaluates cybersecurity needs based on IP
ownership.</small>
</div>
<!-- Sensitive Data -->
<div class="mb-3 question" id="q20">
<label class="form-label mt-3">What type of sensitive data does your organization handle?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-personal"
value="personal">
<label class="form-check-label" for="data-personal">Personal customer data</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-financial"
value="financial">
<label class="form-check-label" for="data-financial">Financial records</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-healthcare"
value="healthcare">
<label class="form-check-label" for="data-healthcare">Healthcare information</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-ip"
value="ip">
<label class="form-check-label" for="data-ip">Intellectual property</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-gov"
value="government">
<label class="form-check-label" for="data-gov">Government data</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="SensitiveData" id="data-payment"
value="payment">
<label class="form-check-label" for="data-payment">Payment card data</label>
</div>
</div>
<small class="form-text text-muted py-3">Identifies required compliance frameworks.</small>
</div>
<!-- Critical Business Systems -->
<div class="mb-3 question" id="q21">
<label class="form-label mt-3">How integrated are your critical business systems?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="IntegrationLevel"
id="integration-fully-integrated" value="fully-integrated" required>
<label class="form-check-label" for="integration-fully-integrated">Fully integrated</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="IntegrationLevel"
id="integration-partially-integrated" value="partially-integrated">
<label class="form-check-label" for="integration-partially-integrated">Partially
integrated</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="IntegrationLevel"
id="integration-mostly-separate" value="mostly-separate">
<label class="form-check-label" for="integration-mostly-separate">Mostly separate</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="IntegrationLevel"
id="integration-completely-isolated" value="completely-isolated">
<label class="form-check-label" for="integration-completely-isolated">Completely
isolated</label>
</div>
</div>
<small class="form-text text-muted py-3">Evaluates potential for cascade failures.</small>
</div>
<!-- Remote Work Policy -->
<div class="mb-3 question" id="q22">
<label class="form-label mt-3">What is your organization's remote work policy?</label>
<hr>
<div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemotePolicy" id="remote-no-remote"
value="no-remote" required>
<label class="form-check-label" for="remote-no-remote">No remote work allowed</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemotePolicy" id="remote-limited-remote"
value="limited-remote">
<label class="form-check-label" for="remote-limited-remote">Limited remote work
options</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemotePolicy" id="remote-hybrid"
value="hybrid">
<label class="form-check-label" for="remote-hybrid">Hybrid work model</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="RemotePolicy" id="remote-fully-remote"
value="fully-remote">
<label class="form-check-label" for="remote-fully-remote">Fully remote operations
available</label>
</div>
</div>
<small class="form-text text-muted py-3">Determines the scope of remote access security
requirements.</small>
</div>
<div class="d-flex justify-content-end mt-4">
<button type="button" class="btn btn-lg btn-outline-secondary me-3" id="back">Back</button>
<button type="submit" class="btn btn-primary btn-lg" id="submit">Next</button>
<button type="button" class="btn btn-primary btn-lg" id="next">Next</button>
</div>
</form>
</div>
</div>
@@ -178,5 +704,5 @@
{{end}}
{{define "bottom"}}
<script src="/static/js/signup.js"></script>
{{end}}
<script src="/static/js/formHandling.js"></script>
{{end}}

43
db/advancedProfile.go Normal file
View File

@@ -0,0 +1,43 @@
package db
type AdvancedProfile struct {
CompanyId int
GeographicDistribution string
CustomerConcentration string
ProductServicePortfolio string
OrganizationalCulture string
SupplierDiversity string
TechnologicalInfrastructure string
IntellectualProperty string
ManagementTeamExperience string
}
// InsertAdvancedProfile inserts a new record into the AdvancedProfile table
func InsertAdvancedProfile(profile AdvancedProfile) (int, error) {
query := `
INSERT INTO AdvancedProfile (
CompanyId, GeographicDistribution, CustomerConcentration, ProductServicePortfolio, OrganizationalCulture,
SupplierDiversity, TechnologicalInfrastructure, IntellectualProperty, ManagementTeamExperience
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING id
`
stmt, err := db.Prepare(query)
if err != nil {
return -2, err
}
defer stmt.Close()
id := 0
err = stmt.QueryRow(
profile.CompanyId, profile.GeographicDistribution, profile.CustomerConcentration, profile.ProductServicePortfolio,
profile.OrganizationalCulture, profile.SupplierDiversity, profile.TechnologicalInfrastructure, profile.IntellectualProperty,
profile.ManagementTeamExperience,
).Scan(&id)
if err != nil {
return -1, err
}
return id, nil
}

View File

@@ -1,24 +1,36 @@
package db
type BasicProfile struct {
CompanyId int
Employees string
Revenue string
Applications string
Compliance string
Industry string
ITDependency string
DataSensitivity string
DataVolume string
NetworkSegmentation string
LegacySystems string
IoTIntegration string
RemoteWork string
BYOD string
VPN string
API string
VendorAccess string
InternalDev string
CompanyId int // Company ID (foreign key reference)
Employees string // Current employee headcount
Revenue string // Annual revenue range
Applications string // Critical business applications
Compliance string // Regulatory frameworks
Industry string // Primary industry sector
ITDependency string // Technology dependency
DataSensitivity string // Sensitive data level
DataVolume string // Data volume (if applicable)
NetworkSegmentation string // Network infrastructure model
LegacySystems string // Legacy systems (if applicable)
IoTIntegration string // IoT integration (if applicable)
RemoteWork string // Remote work details
BYOD string // Bring Your Own Device policy
VPN string // VPN usage policy
API string // API integration (if applicable)
VendorAccess string // Third-party vendor access
InternalDev string // Internal software development activities
// New fields from the advanced form
GeoScope string // Geographic operational scope
CustomerBase string // Customer base distribution
CustomerType string // Primary customer type
ProductPortfolio string // Product/service portfolio
SupplierBase string // Supplier base structure
ITInfrastructure string // IT infrastructure model (comma-separated values)
IPProtection string // Intellectual property protection (comma-separated values)
SensitiveData string // Sensitive data types (comma-separated values)
IntegrationLevel string // Integration level of business systems
RemotePolicy string // Remote work policy
}
// InsertBasicProfile inserts a new record into the BasicProfile table

View File

@@ -26,7 +26,8 @@ func InitDB() {
}
func createTables() {
companyTable := `
tables := []string{
`
CREATE TABLE IF NOT EXISTS Company (
id INTEGER PRIMARY KEY AUTOINCREMENT,
UUID TEXT NOT NULL,
@@ -34,9 +35,9 @@ func createTables() {
TaxId TEXT NOT NULL,
Email TEXT NOT NULL,
Password TEXT NOT NULL
);`
);`,
basicProfileTable := `
`
CREATE TABLE IF NOT EXISTS BasicProfile (
id INTEGER PRIMARY KEY AUTOINCREMENT,
CompanyId INTEGER,
@@ -57,37 +58,33 @@ func createTables() {
API TEXT,
VendorAccess TEXT,
InternalDev TEXT,
GeoScope TEXT, -- Geographic operational scope
CustomerBase TEXT, -- Customer base distribution
CustomerType TEXT, -- Primary customer type
ProductPortfolio TEXT, -- Product/service portfolio
SupplierBase TEXT, -- Supplier base structure
ITInfrastructure TEXT, -- IT infrastructure model (comma-separated values)
IPProtection TEXT, -- Intellectual property protection (comma-separated values)
SensitiveData TEXT, -- Sensitive data types (comma-separated values)
IntegrationLevel TEXT, -- Integration level of business systems
RemotePolicy TEXT, -- Remote work policy
FOREIGN KEY (CompanyId) REFERENCES Company(id)
);`
);`,
advancedProfileTable := `
CREATE TABLE IF NOT EXISTS AdvancedProfile (
`CREATE TABLE IF NOT EXISTS Session (
id INTEGER PRIMARY KEY AUTOINCREMENT,
CompanyId INTEGER,
GeographicDistribution TEXT,
CustomerConcentration TEXT,
ProductServicePortfolio TEXT,
OrganizationalCulture TEXT,
SupplierDiversity TEXT,
TechnologicalInfrastructure TEXT,
IntellectualProperty TEXT,
ManagementTeamExperience TEXT,
FOREIGN KEY (CompanyId) REFERENCES Company(id)
);`
key TEXT NOT NULL,
value TEXT NOT NULL
);`,
_, err := db.Exec(companyTable)
if err != nil {
log.Fatalf("Error creating Company table: %v", err)
`CREATE INDEX IF NOT EXISTS idx_session_key ON Session(key);`,
}
_, err = db.Exec(basicProfileTable)
if err != nil {
log.Fatalf("Error creating BasicProfile table: %v", err)
}
_, err = db.Exec(advancedProfileTable)
if err != nil {
log.Fatalf("Error creating AdvancedProfile table: %v", err)
for _, table := range tables {
_, err := db.Exec(table)
if err != nil {
log.Fatalf("Error creating table: %v", err)
}
}
}

View File

@@ -1,16 +1,23 @@
package db
import (
"math/rand"
"crypto/rand"
"log"
"math/big"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
func GenerateRandomString() string {
const n = 25
const n = 38
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
if err != nil {
log.Println("Error generating random string: ", err)
continue
}
b[i] = letters[num.Int64()]
}
return string(b)
}