@@ -16,45 +16,90 @@ package coredata
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (bi BusinessImpact) MarshalText() ([]byte, error) {
|
type BusinessImpact string
|
||||||
return []byte(bi.String()), nil
|
|
||||||
|
const (
|
||||||
|
BusinessImpactLow BusinessImpact = "LOW"
|
||||||
|
BusinessImpactMedium BusinessImpact = "MEDIUM"
|
||||||
|
BusinessImpactHigh BusinessImpact = "HIGH"
|
||||||
|
BusinessImpactCritical BusinessImpact = "CRITICAL"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (i BusinessImpact) String() string {
|
||||||
|
return string(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bi *BusinessImpact) UnmarshalText(data []byte) error {
|
func (i *BusinessImpact) Scan(value interface{}) error {
|
||||||
val := string(data)
|
switch v := value.(type) {
|
||||||
|
case string:
|
||||||
switch val {
|
switch v {
|
||||||
case BusinessImpactLow.String():
|
case "LOW":
|
||||||
*bi = BusinessImpactLow
|
*i = BusinessImpactLow
|
||||||
case BusinessImpactMedium.String():
|
case "MEDIUM":
|
||||||
*bi = BusinessImpactMedium
|
*i = BusinessImpactMedium
|
||||||
case BusinessImpactHigh.String():
|
case "HIGH":
|
||||||
*bi = BusinessImpactHigh
|
*i = BusinessImpactHigh
|
||||||
case BusinessImpactCritical.String():
|
case "CRITICAL":
|
||||||
*bi = BusinessImpactCritical
|
*i = BusinessImpactCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid BusinessImpact value: %q", v)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid BusinessImpact value: %q", val)
|
return fmt.Errorf("unsupported type for BusinessImpact: %T", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bi BusinessImpact) String() string {
|
func (i BusinessImpact) Value() (driver.Value, error) {
|
||||||
return string(bi)
|
return i.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bi *BusinessImpact) Scan(value any) error {
|
func (i BusinessImpact) MarshalJSON() ([]byte, error) {
|
||||||
val, ok := value.(string)
|
return json.Marshal(i.String())
|
||||||
if !ok {
|
}
|
||||||
return fmt.Errorf("invalid scan source for BusinessImpact, expected string got %T", value)
|
|
||||||
|
func (i *BusinessImpact) UnmarshalJSON(data []byte) error {
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(data, &s); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return bi.UnmarshalText([]byte(val))
|
switch s {
|
||||||
|
case "LOW":
|
||||||
|
*i = BusinessImpactLow
|
||||||
|
case "MEDIUM":
|
||||||
|
*i = BusinessImpactMedium
|
||||||
|
case "HIGH":
|
||||||
|
*i = BusinessImpactHigh
|
||||||
|
case "CRITICAL":
|
||||||
|
*i = BusinessImpactCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid BusinessImpact value: %q", s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bi BusinessImpact) Value() (driver.Value, error) {
|
func (i *BusinessImpact) UnmarshalText(text []byte) error {
|
||||||
return bi.String(), nil
|
var s string
|
||||||
|
if err := json.Unmarshal(text, &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch s {
|
||||||
|
case "LOW":
|
||||||
|
*i = BusinessImpactLow
|
||||||
|
case "MEDIUM":
|
||||||
|
*i = BusinessImpactMedium
|
||||||
|
case "HIGH":
|
||||||
|
*i = BusinessImpactHigh
|
||||||
|
case "CRITICAL":
|
||||||
|
*i = BusinessImpactCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid BusinessImpact value: %q", s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,47 +16,97 @@ package coredata
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ds DataSensitivity) MarshalText() ([]byte, error) {
|
type DataSensitivity string
|
||||||
return []byte(ds.String()), nil
|
|
||||||
|
const (
|
||||||
|
DataSensitivityNone DataSensitivity = "NONE"
|
||||||
|
DataSensitivityLow DataSensitivity = "LOW"
|
||||||
|
DataSensitivityMedium DataSensitivity = "MEDIUM"
|
||||||
|
DataSensitivityHigh DataSensitivity = "HIGH"
|
||||||
|
DataSensitivityCritical DataSensitivity = "CRITICAL"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (i DataSensitivity) String() string {
|
||||||
|
return string(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DataSensitivity) UnmarshalText(data []byte) error {
|
func (i *DataSensitivity) Scan(value interface{}) error {
|
||||||
val := string(data)
|
switch v := value.(type) {
|
||||||
|
case string:
|
||||||
switch val {
|
switch v {
|
||||||
case DataSensitivityNone.String():
|
case "NONE":
|
||||||
*ds = DataSensitivityNone
|
*i = DataSensitivityNone
|
||||||
case DataSensitivityLow.String():
|
case "LOW":
|
||||||
*ds = DataSensitivityLow
|
*i = DataSensitivityLow
|
||||||
case DataSensitivityMedium.String():
|
case "MEDIUM":
|
||||||
*ds = DataSensitivityMedium
|
*i = DataSensitivityMedium
|
||||||
case DataSensitivityHigh.String():
|
case "HIGH":
|
||||||
*ds = DataSensitivityHigh
|
*i = DataSensitivityHigh
|
||||||
case DataSensitivityCritical.String():
|
case "CRITICAL":
|
||||||
*ds = DataSensitivityCritical
|
*i = DataSensitivityCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid DataSensitivity value: %q", v)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid DataSensitivity value: %q", val)
|
return fmt.Errorf("unsupported type for DataSensitivity: %T", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds DataSensitivity) String() string {
|
func (i DataSensitivity) Value() (driver.Value, error) {
|
||||||
return string(ds)
|
return i.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DataSensitivity) Scan(value any) error {
|
func (i DataSensitivity) MarshalJSON() ([]byte, error) {
|
||||||
val, ok := value.(string)
|
return json.Marshal(i.String())
|
||||||
if !ok {
|
}
|
||||||
return fmt.Errorf("invalid scan source for DataSensitivity, expected string got %T", value)
|
|
||||||
|
func (i *DataSensitivity) UnmarshalJSON(data []byte) error {
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(data, &s); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ds.UnmarshalText([]byte(val))
|
switch s {
|
||||||
|
case "NONE":
|
||||||
|
*i = DataSensitivityNone
|
||||||
|
case "LOW":
|
||||||
|
*i = DataSensitivityLow
|
||||||
|
case "MEDIUM":
|
||||||
|
*i = DataSensitivityMedium
|
||||||
|
case "HIGH":
|
||||||
|
*i = DataSensitivityHigh
|
||||||
|
case "CRITICAL":
|
||||||
|
*i = DataSensitivityCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid DataSensitivity value: %q", s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds DataSensitivity) Value() (driver.Value, error) {
|
func (i *DataSensitivity) UnmarshalText(text []byte) error {
|
||||||
return ds.String(), nil
|
var s string
|
||||||
|
if err := json.Unmarshal(text, &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch s {
|
||||||
|
case "NONE":
|
||||||
|
*i = DataSensitivityNone
|
||||||
|
case "LOW":
|
||||||
|
*i = DataSensitivityLow
|
||||||
|
case "MEDIUM":
|
||||||
|
*i = DataSensitivityMedium
|
||||||
|
case "HIGH":
|
||||||
|
*i = DataSensitivityHigh
|
||||||
|
case "CRITICAL":
|
||||||
|
*i = DataSensitivityCritical
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid DataSensitivity value: %q", s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,33 +43,9 @@ type (
|
|||||||
UpdatedAt time.Time `db:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataSensitivity represents the level of data sensitivity handled by a vendor
|
|
||||||
DataSensitivity string
|
|
||||||
|
|
||||||
// BusinessImpact represents the impact level the vendor has on business operations
|
|
||||||
BusinessImpact string
|
|
||||||
|
|
||||||
// RiskAssessments is a collection of RiskAssessment objects
|
|
||||||
VendorRiskAssessments []*VendorRiskAssessment
|
VendorRiskAssessments []*VendorRiskAssessment
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants for DataSensitivity
|
|
||||||
const (
|
|
||||||
DataSensitivityNone DataSensitivity = "NONE" // No sensitive data
|
|
||||||
DataSensitivityLow DataSensitivity = "LOW" // Public or non-sensitive data
|
|
||||||
DataSensitivityMedium DataSensitivity = "MEDIUM" // Internal/restricted data
|
|
||||||
DataSensitivityHigh DataSensitivity = "HIGH" // Confidential data
|
|
||||||
DataSensitivityCritical DataSensitivity = "CRITICAL" // Regulated/PII/financial data
|
|
||||||
)
|
|
||||||
|
|
||||||
// Constants for BusinessImpact
|
|
||||||
const (
|
|
||||||
BusinessImpactLow BusinessImpact = "LOW" // Minimal impact on business
|
|
||||||
BusinessImpactMedium BusinessImpact = "MEDIUM" // Moderate impact on business
|
|
||||||
BusinessImpactHigh BusinessImpact = "HIGH" // Significant business impact
|
|
||||||
BusinessImpactCritical BusinessImpact = "CRITICAL" // Critical to business operations
|
|
||||||
)
|
|
||||||
|
|
||||||
func (v VendorRiskAssessment) CursorKey(orderBy VendorRiskAssessmentOrderField) page.CursorKey {
|
func (v VendorRiskAssessment) CursorKey(orderBy VendorRiskAssessmentOrderField) page.CursorKey {
|
||||||
switch orderBy {
|
switch orderBy {
|
||||||
case VendorRiskAssessmentOrderFieldCreatedAt:
|
case VendorRiskAssessmentOrderFieldCreatedAt:
|
||||||
|
|||||||
Reference in New Issue
Block a user