diff --git a/external/resolvedSchemas.json b/external/resolvedSchemas.json index 39d4209..74d78e2 100644 --- a/external/resolvedSchemas.json +++ b/external/resolvedSchemas.json @@ -10825,6 +10825,239 @@ }, "required": ["_key", "_class", "_type", "name", "displayName", "ipAddress"] }, + "#IpRange": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "#IpRange", + "description": "consecutive set of IP addresses used for network addressing and management.", + "type": "object", + "properties": { + "_class": { + "description": "One or more classes conforming to a standard, abstract security data model. For example, an EC2 instance will have '_class':'Host'.", + "oneOf": [ + { "type": "string", "minLength": 2 }, + { + "type": "array", + "minItems": 1, + "items": { "type": "string", "minLength": 2 } + } + ], + "inherited": true + }, + "_key": { + "description": "An identifier unique within the scope containing the object. For example, for a Bitbucket repo, this will be the GUID of the repo as assigned by Bitbucket. For an IAM Role, this will be the ARN of the role.", + "type": "string", + "minLength": 10, + "inherited": true + }, + "_type": { + "description": "The type of object, typically reflecting the vendor and resource type. For example, 'aws_iam_user'. In some cases, a system knows about a type of entity that other systems know about, such as 'user_endpoint' or 'cve'.", + "type": "string", + "minLength": 3, + "inherited": true + }, + "active": { + "description": "Indicates if the IP Range is currently active", + "type": "boolean" + }, + "asn": { + "description": "Indicates IP version 4 or 6", + "type": "string", + "format": "asn" + }, + "cidr": { + "description": "The cidr that determines the IP Range", + "type": "string", + "format": "ipCidr" + }, + "classification": { + "description": "The sensitivity of the data; should match company data classification scheme", + "type": ["string", "null"], + "examples": ["critical", "confidential", "internal", "public"], + "inherited": true + }, + "complianceStatus": { + "description": "The compliance status of the entity, as a percentage of compliancy.", + "type": "number", + "minimum": 0, + "maximum": 1, + "inherited": true + }, + "country": { + "description": "Country where the IP range is registered or assigned", + "type": "string" + }, + "createdBy": { + "description": "The source/principal/user that created the entity", + "type": "string", + "inherited": true + }, + "createdOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was created at the source. This is different than `_createdOn` which is the timestamp the entity was first ingested into JupiterOne.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "criticality": { + "description": "A number that represents the value or criticality of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "deletedBy": { + "description": "The source/principal/user that deleted the entity", + "type": "string", + "inherited": true + }, + "deletedOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was deleted at the source.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "description": { + "description": "An extended description of this entity.", + "type": "string", + "inherited": true + }, + "discoveredBy": { + "description": "The source/principal/user that discovered the entity", + "type": "string", + "inherited": true + }, + "discoveredOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was discovered.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "displayName": { + "description": "Display name, e.g. a person's preferred name or an AWS account alias", + "type": "string", + "inherited": true + }, + "expiresOn": { + "description": "If the entity is a temporary resource, optionally set the expiration date. For example, the expiration date of an SSL cert.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "id": { + "description": "Identifiers of this entity assigned by the providers. Values are expected to be unique within the provider scope.", + "anyOf": [ + { "type": "string" }, + { "type": "array", "items": { "type": "string" } } + ], + "inherited": true + }, + "name": { + "description": "Name of this entity", + "type": "string", + "inherited": true + }, + "notes": { + "description": "User provided notes about this entity", + "type": "array", + "items": { "type": "string" }, + "inherited": true + }, + "owner": { + "description": "The owner of this entity. This could reference the name of the owner, or as reference ID/key to another entity in the graph as the owner.", + "type": "string", + "inherited": true + }, + "public": { + "description": "Indicates if the IP Range is public", + "type": "boolean" + }, + "risk": { + "description": "The risk level of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "source": { "description": "The IP Range source", "type": "string" }, + "status": { + "description": "Status of this entity set by the external source system or by a user, e.g. Active, Inactive, Decommissioned", + "type": "string", + "examples": [ + "active", + "inactive", + "suspended", + "terminated", + "open", + "closed", + "pending", + "unknown", + "other" + ], + "inherited": true + }, + "summary": { + "description": "A summary / short description of this entity.", + "type": "string", + "inherited": true + }, + "tags": { + "description": "An array of unnamed tags", + "type": "array", + "items": { "type": "string" }, + "inherited": true + }, + "temporary": { + "description": "Indicates if this node is a temporary resource, such as a lambda instance or an EC2 instance started by ECS.", + "type": "boolean", + "inherited": true + }, + "trust": { + "description": "The trust level of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "trusted": { + "description": "Indicates if this is a trusted resource. For example, a trusted Network, Host, Device, Application, Person, User, or Vendor.", + "type": "boolean", + "inherited": true + }, + "updatedBy": { + "description": "The source/principal/user that updated the entity", + "type": "string", + "inherited": true + }, + "updatedOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was last updated at the source.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "validated": { + "description": "Indicates if this node has been validated as a known/valid Entity.", + "type": "boolean", + "inherited": true + }, + "webLink": { + "description": "Web link to the source. For example: https://console.aws.amazon.com/iam/home#/roles/Administrator. This property is used by the UI to add a hyperlink to the entity.", + "type": "string", + "format": "uri", + "inherited": true + } + }, + "required": [ + "_key", + "_class", + "_type", + "name", + "displayName", + "source", + "active", + "cidr", + "public", + "asn" + ] + }, "#Issue": { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "#Issue", @@ -13755,6 +13988,247 @@ "content" ] }, + "#Port": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "#Port", + "description": "Network communication endpoint", + "type": "object", + "properties": { + "_class": { + "description": "One or more classes conforming to a standard, abstract security data model. For example, an EC2 instance will have '_class':'Host'.", + "oneOf": [ + { "type": "string", "minLength": 2 }, + { + "type": "array", + "minItems": 1, + "items": { "type": "string", "minLength": 2 } + } + ], + "inherited": true + }, + "_key": { + "description": "An identifier unique within the scope containing the object. For example, for a Bitbucket repo, this will be the GUID of the repo as assigned by Bitbucket. For an IAM Role, this will be the ARN of the role.", + "type": "string", + "minLength": 10, + "inherited": true + }, + "_type": { + "description": "The type of object, typically reflecting the vendor and resource type. For example, 'aws_iam_user'. In some cases, a system knows about a type of entity that other systems know about, such as 'user_endpoint' or 'cve'.", + "type": "string", + "minLength": 3, + "inherited": true + }, + "active": { + "description": "Indicates if this entity is currently active.", + "type": "boolean", + "inherited": true + }, + "banner": { + "description": "Provides information about the service running on the port.", + "type": "string" + }, + "classification": { + "description": "The sensitivity of the data; should match company data classification scheme", + "type": ["string", "null"], + "examples": ["critical", "confidential", "internal", "public"], + "inherited": true + }, + "complianceStatus": { + "description": "The compliance status of the entity, as a percentage of compliancy.", + "type": "number", + "minimum": 0, + "maximum": 1, + "inherited": true + }, + "createdBy": { + "description": "The source/principal/user that created the entity", + "type": "string", + "inherited": true + }, + "createdOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was created at the source. This is different than `_createdOn` which is the timestamp the entity was first ingested into JupiterOne.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "criticality": { + "description": "A number that represents the value or criticality of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "deletedBy": { + "description": "The source/principal/user that deleted the entity", + "type": "string", + "inherited": true + }, + "deletedOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was deleted at the source.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "description": { + "description": "An extended description of this entity.", + "type": "string", + "inherited": true + }, + "discoveredBy": { + "description": "The source/principal/user that discovered the entity", + "type": "string", + "inherited": true + }, + "discoveredOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was discovered.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "displayName": { + "description": "Display name, e.g. a person's preferred name or an AWS account alias", + "type": "string", + "inherited": true + }, + "expiresOn": { + "description": "If the entity is a temporary resource, optionally set the expiration date. For example, the expiration date of an SSL cert.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "id": { + "description": "Identifiers of this entity assigned by the providers. Values are expected to be unique within the provider scope.", + "anyOf": [ + { "type": "string" }, + { "type": "array", "items": { "type": "string" } } + ], + "inherited": true + }, + "name": { + "description": "Name of this entity", + "type": "string", + "inherited": true + }, + "notes": { + "description": "User provided notes about this entity", + "type": "array", + "items": { "type": "string" }, + "inherited": true + }, + "open": { + "description": "Indicates if the Port is accessible and available for communication.", + "type": "boolean" + }, + "owner": { + "description": "The owner of this entity. This could reference the name of the owner, or as reference ID/key to another entity in the graph as the owner.", + "type": "string", + "inherited": true + }, + "port": { + "description": "Port number", + "type": "integer", + "minimum": 1, + "maximum": 65536 + }, + "protocol": { + "description": "Communication protocol used last time in the Port.", + "type": "string", + "enum": ["TCP", "UDP", "TCP/UDP", "UDP/TCP"] + }, + "public": { + "description": "Indicates if this is a public-facing resource (e.g. a public IP or public DNS record) or if the entity is publicly accessible. Default is false.", + "type": "boolean", + "inherited": true + }, + "risk": { + "description": "The risk level of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "service": { + "description": " Indicates the type or protocol of the service running on the port.", + "type": "string" + }, + "status": { + "description": "Status of this entity set by the external source system or by a user, e.g. Active, Inactive, Decommissioned", + "type": "string", + "examples": [ + "active", + "inactive", + "suspended", + "terminated", + "open", + "closed", + "pending", + "unknown", + "other" + ], + "inherited": true + }, + "summary": { + "description": "A summary / short description of this entity.", + "type": "string", + "inherited": true + }, + "tags": { + "description": "An array of unnamed tags", + "type": "array", + "items": { "type": "string" }, + "inherited": true + }, + "temporary": { + "description": "Indicates if this node is a temporary resource, such as a lambda instance or an EC2 instance started by ECS.", + "type": "boolean", + "inherited": true + }, + "trust": { + "description": "The trust level of this entity, on a scale between 1-10.", + "type": "integer", + "minimum": 1, + "maximum": 10, + "inherited": true + }, + "trusted": { + "description": "Indicates if this is a trusted resource. For example, a trusted Network, Host, Device, Application, Person, User, or Vendor.", + "type": "boolean", + "inherited": true + }, + "updatedBy": { + "description": "The source/principal/user that updated the entity", + "type": "string", + "inherited": true + }, + "updatedOn": { + "description": "The timestamp (in milliseconds since epoch) when the entity was last updated at the source.", + "type": "number", + "format": "date-time", + "inherited": true + }, + "validated": { + "description": "Indicates if this node has been validated as a known/valid Entity.", + "type": "boolean", + "inherited": true + }, + "webLink": { + "description": "Web link to the source. For example: https://console.aws.amazon.com/iam/home#/roles/Administrator. This property is used by the UI to add a hyperlink to the entity.", + "type": "string", + "format": "uri", + "inherited": true + } + }, + "required": [ + "_key", + "_class", + "_type", + "name", + "displayName", + "protocol", + "open", + "port" + ] + }, "#Problem": { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "#Problem", diff --git a/src/IntegrationSchema.ts b/src/IntegrationSchema.ts index e73865c..1e39c30 100644 --- a/src/IntegrationSchema.ts +++ b/src/IntegrationSchema.ts @@ -28,494 +28,402 @@ import WorkloadJson from './schemas/Workload.json'; export const Workload = WorkloadJson; IntegrationSchema.addSchema(Workload); - import WorkflowJson from './schemas/Workflow.json'; export const Workflow = WorkflowJson; IntegrationSchema.addSchema(Workflow); - import WeaknessJson from './schemas/Weakness.json'; export const Weakness = WeaknessJson; IntegrationSchema.addSchema(Weakness); - import VulnerabilityJson from './schemas/Vulnerability.json'; export const Vulnerability = VulnerabilityJson; IntegrationSchema.addSchema(Vulnerability); - import VendorJson from './schemas/Vendor.json'; export const Vendor = VendorJson; IntegrationSchema.addSchema(Vendor); - import VaultJson from './schemas/Vault.json'; export const Vault = VaultJson; IntegrationSchema.addSchema(Vault); - import UserJson from './schemas/User.json'; export const User = UserJson; IntegrationSchema.addSchema(User); - import UserGroupJson from './schemas/UserGroup.json'; export const UserGroup = UserGroupJson; IntegrationSchema.addSchema(UserGroup); - import TrainingJson from './schemas/Training.json'; export const Training = TrainingJson; IntegrationSchema.addSchema(Training); - import ThreatIntelJson from './schemas/ThreatIntel.json'; export const ThreatIntel = ThreatIntelJson; IntegrationSchema.addSchema(ThreatIntel); - import TeamJson from './schemas/Team.json'; export const Team = TeamJson; IntegrationSchema.addSchema(Team); - import TaskJson from './schemas/Task.json'; export const Task = TaskJson; IntegrationSchema.addSchema(Task); - import SubscriptionJson from './schemas/Subscription.json'; export const Subscription = SubscriptionJson; IntegrationSchema.addSchema(Subscription); - import StandardJson from './schemas/Standard.json'; export const Standard = StandardJson; IntegrationSchema.addSchema(Standard); - import SiteJson from './schemas/Site.json'; export const Site = SiteJson; IntegrationSchema.addSchema(Site); - import ServiceJson from './schemas/Service.json'; export const Service = ServiceJson; IntegrationSchema.addSchema(Service); - import SectionJson from './schemas/Section.json'; export const Section = SectionJson; IntegrationSchema.addSchema(Section); - import SecretJson from './schemas/Secret.json'; export const Secret = SecretJson; IntegrationSchema.addSchema(Secret); - import ScannerJson from './schemas/Scanner.json'; export const Scanner = ScannerJson; IntegrationSchema.addSchema(Scanner); - import RulesetJson from './schemas/Ruleset.json'; export const Ruleset = RulesetJson; IntegrationSchema.addSchema(Ruleset); - import RuleJson from './schemas/Rule.json'; export const Rule = RuleJson; IntegrationSchema.addSchema(Rule); - import RootJson from './schemas/Root.json'; export const Root = RootJson; IntegrationSchema.addSchema(Root); - import RiskJson from './schemas/Risk.json'; export const Risk = RiskJson; IntegrationSchema.addSchema(Risk); - import ReviewJson from './schemas/Review.json'; export const Review = ReviewJson; IntegrationSchema.addSchema(Review); - import ResourceJson from './schemas/Resource.json'; export const Resource = ResourceJson; IntegrationSchema.addSchema(Resource); - import RequirementJson from './schemas/Requirement.json'; export const Requirement = RequirementJson; IntegrationSchema.addSchema(Requirement); - import RepositoryJson from './schemas/Repository.json'; export const Repository = RepositoryJson; IntegrationSchema.addSchema(Repository); - import RecordJson from './schemas/Record.json'; export const Record = RecordJson; IntegrationSchema.addSchema(Record); - import RecordEntityJson from './schemas/RecordEntity.json'; export const RecordEntity = RecordEntityJson; IntegrationSchema.addSchema(RecordEntity); - import QueueJson from './schemas/Queue.json'; export const Queue = QueueJson; IntegrationSchema.addSchema(Queue); - import QuestionJson from './schemas/Question.json'; export const Question = QuestionJson; IntegrationSchema.addSchema(Question); - import ProjectJson from './schemas/Project.json'; export const Project = ProjectJson; IntegrationSchema.addSchema(Project); - import ProgramJson from './schemas/Program.json'; export const Program = ProgramJson; IntegrationSchema.addSchema(Program); - import ProductJson from './schemas/Product.json'; export const Product = ProductJson; IntegrationSchema.addSchema(Product); - import ProcessJson from './schemas/Process.json'; export const Process = ProcessJson; IntegrationSchema.addSchema(Process); - import ProcedureJson from './schemas/Procedure.json'; export const Procedure = ProcedureJson; IntegrationSchema.addSchema(Procedure); - import ProblemJson from './schemas/Problem.json'; export const Problem = ProblemJson; IntegrationSchema.addSchema(Problem); - import PRJson from './schemas/PR.json'; export const PR = PRJson; IntegrationSchema.addSchema(PR); - import PolicyJson from './schemas/Policy.json'; export const Policy = PolicyJson; IntegrationSchema.addSchema(Policy); - import PersonJson from './schemas/Person.json'; export const Person = PersonJson; IntegrationSchema.addSchema(Person); - import PasswordPolicyJson from './schemas/PasswordPolicy.json'; export const PasswordPolicy = PasswordPolicyJson; IntegrationSchema.addSchema(PasswordPolicy); - import OrganizationJson from './schemas/Organization.json'; export const Organization = OrganizationJson; IntegrationSchema.addSchema(Organization); - import NetworkJson from './schemas/Network.json'; export const Network = NetworkJson; IntegrationSchema.addSchema(Network); - import NetworkInterfaceJson from './schemas/NetworkInterface.json'; export const NetworkInterface = NetworkInterfaceJson; IntegrationSchema.addSchema(NetworkInterface); - import NetworkEndpointJson from './schemas/NetworkEndpoint.json'; export const NetworkEndpoint = NetworkEndpointJson; IntegrationSchema.addSchema(NetworkEndpoint); - import ModuleJson from './schemas/Module.json'; export const Module = ModuleJson; IntegrationSchema.addSchema(Module); - import ModelJson from './schemas/Model.json'; export const Model = ModelJson; IntegrationSchema.addSchema(Model); - import LogsJson from './schemas/Logs.json'; export const Logs = LogsJson; IntegrationSchema.addSchema(Logs); - import KeyJson from './schemas/Key.json'; export const Key = KeyJson; IntegrationSchema.addSchema(Key); - import IssueJson from './schemas/Issue.json'; export const Issue = IssueJson; IntegrationSchema.addSchema(Issue); - import IpAddressJson from './schemas/IpAddress.json'; export const IpAddress = IpAddressJson; IntegrationSchema.addSchema(IpAddress); - import InternetJson from './schemas/Internet.json'; export const Internet = InternetJson; IntegrationSchema.addSchema(Internet); - import IncidentJson from './schemas/Incident.json'; export const Incident = IncidentJson; IntegrationSchema.addSchema(Incident); - import ImageJson from './schemas/Image.json'; export const Image = ImageJson; IntegrationSchema.addSchema(Image); - import HostJson from './schemas/Host.json'; export const Host = HostJson; IntegrationSchema.addSchema(Host); - import HostAgentJson from './schemas/HostAgent.json'; export const HostAgent = HostAgentJson; IntegrationSchema.addSchema(HostAgent); - import GroupJson from './schemas/Group.json'; export const Group = GroupJson; IntegrationSchema.addSchema(Group); - import GraphObjectJson from './schemas/GraphObject.json'; export const GraphObject = GraphObjectJson; IntegrationSchema.addSchema(GraphObject); - import GatewayJson from './schemas/Gateway.json'; export const Gateway = GatewayJson; IntegrationSchema.addSchema(Gateway); - import FunctionJson from './schemas/Function.json'; export const Function = FunctionJson; IntegrationSchema.addSchema(Function); - import FrameworkJson from './schemas/Framework.json'; export const Framework = FrameworkJson; IntegrationSchema.addSchema(Framework); - import FirewallJson from './schemas/Firewall.json'; export const Firewall = FirewallJson; IntegrationSchema.addSchema(Firewall); - import FindingJson from './schemas/Finding.json'; export const Finding = FindingJson; IntegrationSchema.addSchema(Finding); - import EntityJson from './schemas/Entity.json'; export const Entity = EntityJson; IntegrationSchema.addSchema(Entity); - import DomainZoneJson from './schemas/DomainZone.json'; export const DomainZone = DomainZoneJson; IntegrationSchema.addSchema(DomainZone); - import DomainRecordJson from './schemas/DomainRecord.json'; export const DomainRecord = DomainRecordJson; IntegrationSchema.addSchema(DomainRecord); - import DomainJson from './schemas/Domain.json'; export const Domain = DomainJson; IntegrationSchema.addSchema(Domain); - import DocumentJson from './schemas/Document.json'; export const Document = DocumentJson; IntegrationSchema.addSchema(Document); - import DiskJson from './schemas/Disk.json'; export const Disk = DiskJson; IntegrationSchema.addSchema(Disk); - import DirectoryJson from './schemas/Directory.json'; export const Directory = DirectoryJson; IntegrationSchema.addSchema(Directory); - import DeviceJson from './schemas/Device.json'; export const Device = DeviceJson; IntegrationSchema.addSchema(Device); - import DeploymentJson from './schemas/Deployment.json'; export const Deployment = DeploymentJson; IntegrationSchema.addSchema(Deployment); - import DataStoreJson from './schemas/DataStore.json'; export const DataStore = DataStoreJson; IntegrationSchema.addSchema(DataStore); - import DataObjectJson from './schemas/DataObject.json'; export const DataObject = DataObjectJson; IntegrationSchema.addSchema(DataObject); - import DataCollectionJson from './schemas/DataCollection.json'; export const DataCollection = DataCollectionJson; IntegrationSchema.addSchema(DataCollection); - import DatabaseJson from './schemas/Database.json'; export const Database = DatabaseJson; IntegrationSchema.addSchema(Database); - import CryptoKeyJson from './schemas/CryptoKey.json'; export const CryptoKey = CryptoKeyJson; IntegrationSchema.addSchema(CryptoKey); - import ControlPolicyJson from './schemas/ControlPolicy.json'; export const ControlPolicy = ControlPolicyJson; IntegrationSchema.addSchema(ControlPolicy); - import ControlJson from './schemas/Control.json'; export const Control = ControlJson; IntegrationSchema.addSchema(Control); - import ContainerJson from './schemas/Container.json'; export const Container = ContainerJson; IntegrationSchema.addSchema(Container); - import ConfigurationJson from './schemas/Configuration.json'; export const Configuration = ConfigurationJson; IntegrationSchema.addSchema(Configuration); - import CodeReviewJson from './schemas/CodeReview.json'; export const CodeReview = CodeReviewJson; IntegrationSchema.addSchema(CodeReview); - import CodeRepoJson from './schemas/CodeRepo.json'; export const CodeRepo = CodeRepoJson; IntegrationSchema.addSchema(CodeRepo); - import CodeModuleJson from './schemas/CodeModule.json'; export const CodeModule = CodeModuleJson; IntegrationSchema.addSchema(CodeModule); - import CodeDeployJson from './schemas/CodeDeploy.json'; export const CodeDeploy = CodeDeployJson; IntegrationSchema.addSchema(CodeDeploy); - import CodeCommitJson from './schemas/CodeCommit.json'; export const CodeCommit = CodeCommitJson; IntegrationSchema.addSchema(CodeCommit); - import ClusterJson from './schemas/Cluster.json'; export const Cluster = ClusterJson; IntegrationSchema.addSchema(Cluster); - import ChannelJson from './schemas/Channel.json'; export const Channel = ChannelJson; IntegrationSchema.addSchema(Channel); - import CertificateJson from './schemas/Certificate.json'; export const Certificate = CertificateJson; IntegrationSchema.addSchema(Certificate); - import BackupJson from './schemas/Backup.json'; export const Backup = BackupJson; IntegrationSchema.addSchema(Backup); - import AttackerJson from './schemas/Attacker.json'; export const Attacker = AttackerJson; IntegrationSchema.addSchema(Attacker); - import AssessmentJson from './schemas/Assessment.json'; export const Assessment = AssessmentJson; IntegrationSchema.addSchema(Assessment); - import ApplicationJson from './schemas/Application.json'; export const Application = ApplicationJson; IntegrationSchema.addSchema(Application); - import ApplicationEndpointJson from './schemas/ApplicationEndpoint.json'; export const ApplicationEndpoint = ApplicationEndpointJson; IntegrationSchema.addSchema(ApplicationEndpoint); - import AlertJson from './schemas/Alert.json'; export const Alert = AlertJson; IntegrationSchema.addSchema(Alert); - import AccountJson from './schemas/Account.json'; export const Account = AccountJson; IntegrationSchema.addSchema(Account); - import AccessRoleJson from './schemas/AccessRole.json'; export const AccessRole = AccessRoleJson; IntegrationSchema.addSchema(AccessRole); - import AccessPolicyJson from './schemas/AccessPolicy.json'; export const AccessPolicy = AccessPolicyJson; IntegrationSchema.addSchema(AccessPolicy); - import AccessKeyJson from './schemas/AccessKey.json'; export const AccessKey = AccessKeyJson; IntegrationSchema.addSchema(AccessKey); +import IpRangeJson from './schemas/IpRange.json'; +export const IpRange = IpRangeJson; +IntegrationSchema.addSchema(IpRange); +import PortJson from './schemas/Port.json'; +export const Port = PortJson; +IntegrationSchema.addSchema(Port); diff --git a/src/registerFormats.ts b/src/registerFormats.ts index d39a818..e379a24 100644 --- a/src/registerFormats.ts +++ b/src/registerFormats.ts @@ -3,22 +3,31 @@ import Ajv from 'ajv'; const ipv4 = addFormats.get('ipv4') as RegExp; const ipv6 = addFormats.get('ipv6') as RegExp; -const ipv4CidrRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[12]?[0-9])$/; -const ipv6CidrRegex = /^([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^([0-9a-fA-F]{1,4}:){1,7}:\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^::\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{1,4}$/; +const ipv4CidrRegex = + /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[12]?[0-9])$/; +const ipv6CidrRegex = + /^([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^([0-9a-fA-F]{1,4}:){1,7}:\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^::\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{1,4}$/; +const asnRegex = /^AS\d{2,6}$/; const isValidIpFormat = { name: 'ip', - fn: (x) => ipv4.test(x) || ipv6.test(x), + fn: (x: string) => ipv4.test(x) || ipv6.test(x), }; const isValidIpCidrFormat = { name: 'ipCidr', - fn: (x) => ipv4CidrRegex.test(x) || ipv6CidrRegex.test(x), + fn: (x: string) => ipv4CidrRegex.test(x) || ipv6CidrRegex.test(x), +}; + +const isValidASN = { + name: 'asn', + fn: (x: string) => asnRegex.test(x), }; export function registerFormats(ajvInstance: Ajv): void { ajvInstance.addFormat(isValidIpFormat.name, isValidIpFormat.fn); ajvInstance.addFormat(isValidIpCidrFormat.name, isValidIpCidrFormat.fn); + ajvInstance.addFormat(isValidASN.name, isValidASN.fn); addFormats(ajvInstance); } diff --git a/src/registerSchemas.ts b/src/registerSchemas.ts index 2a45b86..e545e83 100644 --- a/src/registerSchemas.ts +++ b/src/registerSchemas.ts @@ -53,6 +53,7 @@ import ImageJson from './schemas/Image.json'; import IncidentJson from './schemas/Incident.json'; import InternetJson from './schemas/Internet.json'; import IpAddressJson from './schemas/IpAddress.json'; +import IpRangeJson from './schemas/IpRange.json'; import IssueJson from './schemas/Issue.json'; import KeyJson from './schemas/Key.json'; import LogsJson from './schemas/Logs.json'; @@ -66,6 +67,7 @@ import PRJson from './schemas/PR.json'; import PasswordPolicyJson from './schemas/PasswordPolicy.json'; import PersonJson from './schemas/Person.json'; import PolicyJson from './schemas/Policy.json'; +import PortJson from './schemas/Port.json'; import ProblemJson from './schemas/Problem.json'; import ProcedureJson from './schemas/Procedure.json'; import ProcessJson from './schemas/Process.json'; @@ -154,6 +156,7 @@ export function registerSchemas(ajvInstance: Ajv): void { ajvInstance.addSchema(IncidentJson); ajvInstance.addSchema(InternetJson); ajvInstance.addSchema(IpAddressJson); + ajvInstance.addSchema(IpRangeJson); ajvInstance.addSchema(IssueJson); ajvInstance.addSchema(KeyJson); ajvInstance.addSchema(LogsJson); @@ -167,6 +170,7 @@ export function registerSchemas(ajvInstance: Ajv): void { ajvInstance.addSchema(PasswordPolicyJson); ajvInstance.addSchema(PersonJson); ajvInstance.addSchema(PolicyJson); + ajvInstance.addSchema(PortJson); ajvInstance.addSchema(ProblemJson); ajvInstance.addSchema(ProcedureJson); ajvInstance.addSchema(ProcessJson); diff --git a/src/schemas/IpRange.json b/src/schemas/IpRange.json new file mode 100644 index 0000000..9d2c4b5 --- /dev/null +++ b/src/schemas/IpRange.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "#IpRange", + "description": "consecutive set of IP addresses used for network addressing and management.", + "type": "object", + "allOf": [ + { + "$ref": "#Entity" + }, + { + "properties": { + "source": { + "description": "The IP Range source", + "type": "string" + }, + "active": { + "description": "Indicates if the IP Range is currently active", + "type": "boolean" + }, + "cidr": { + "description": "The cidr that determines the IP Range", + "type": "string", + "format": "ipCidr" + }, + "public": { + "description": "Indicates if the IP Range is private or public. If the source does not provide this value, it is computed using the CIDR", + "type": "boolean" + }, + "asn": { + "description": "Autonomous System Number that identifies a routing policy", + "type": "string", + "format": "asn" + }, + "country": { + "description": "Country where the IP range is registered or assigned", + "type": "string" + } + }, + "required": ["source", "active", "cidr", "public", "asn"] + } + ] +} diff --git a/src/schemas/Port.json b/src/schemas/Port.json new file mode 100644 index 0000000..6c6a837 --- /dev/null +++ b/src/schemas/Port.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "#Port", + "description": "A number assigned to identify a network communication endpoint.", + "type": "object", + "allOf": [ + { + "$ref": "#Entity" + }, + { + "properties": { + "protocol": { + "description": "Communication protocol last observed being used on this port.", + "type": "string", + "enum": ["TCP", "UDP", "TCP/UDP", "UDP/TCP"] + }, + "open": { + "description": "Indicates if the port is open or shut communication.", + "type": "boolean" + }, + "port": { + "description": "Port number", + "type": "integer", + "minimum": 1, + "maximum": 65536 + }, + "banner": { + "description": "Provides information about the service running on the port.", + "type": "string" + }, + "service": { + "description": "Indicates the type or protocol of the service running on the port.", + "type": "string" + } + }, + "required": ["protocol", "open", "port"] + } + ] +} diff --git a/src/validateEntityWithSchema.test.ts b/src/validateEntityWithSchema.test.ts index 7d6ae77..57c1bec 100644 --- a/src/validateEntityWithSchema.test.ts +++ b/src/validateEntityWithSchema.test.ts @@ -334,3 +334,59 @@ describe('#DataCollection', () => { ).not.toThrow(); }); }); + +describe('#IpRange', () => { + const requiredProperties = { + ...requiredGraphObjectProperties, + _class: ['IpRange'], + source: 'test', + active: true, + cidr: '105.115.141.50/24', + public: true, + asn: 'AS4676', + }; + + test('Should successfully validate required properties', () => { + expect(() => + validateEntityWithSchema({ + ...requiredProperties, + } as any), + ).not.toThrow(); + }); + + test('disallows invalid cidr', () => { + expect(() => + validateEntityWithSchema({ + ...requiredProperties, + cidr: '256.0.0.0/24', + } as any), + ).toThrow(/must match format/); + }); + + test('disallows invalid asn', () => { + expect(() => + validateEntityWithSchema({ + ...requiredProperties, + asn: 'AS2', + } as any), + ).toThrow(/must match format/); + }); +}); + +describe('#Port', () => { + const requiredProperties = { + ...requiredGraphObjectProperties, + _class: ['Port'], + protocol: 'TCP', + open: true, + port: 80, + }; + + test('Should successfully validate required properties', () => { + expect(() => + validateEntityWithSchema({ + ...requiredProperties, + } as any), + ).not.toThrow(); + }); +});