-
Notifications
You must be signed in to change notification settings - Fork 38
Add size constraints to CTIM collection fields (XDR-46972) #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a927b2e
28787a9
bc08b36
8237a23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,12 @@ | |
|
|
||
| (def ctim-schema-version (ctim-version)) | ||
|
|
||
| ;; Default size limit for collection fields (strings, references, etc.) | ||
| (def default-collection-max-len 500) | ||
|
|
||
| ;; Max number of actions allowed in a single relation's relation_info | ||
| (def max-relation-actions 1000) | ||
|
|
||
| (def-eq CTIMSchemaVersion ctim-schema-version) | ||
|
|
||
| (cs/def ::ctim-schema-version | ||
|
|
@@ -175,9 +181,9 @@ | |
| (f/entry :description Markdown) | ||
| (f/entry :url URI | ||
| :description "A URL reference to an external resource.") | ||
| (f/entry :hashes f/any-string-seq | ||
| (f/entry :hashes (f/seq-of ShortString) | ||
| :description "Specifies a dictionary of hashes for the contents of the url.") | ||
| (f/entry :external_id f/any-str | ||
| (f/entry :external_id ShortString | ||
| :description "An identifier for the external reference content."))) | ||
| :description (str "External references are used to describe pointers to information " | ||
| "represented outside of CTIM. For example, a Malware object could " | ||
|
|
@@ -191,13 +197,14 @@ | |
| (f/required-entries | ||
| (f/entry :id ID | ||
| :description "Globally unique URI identifying this object.") | ||
| (f/entry :type f/any-str) | ||
| (f/entry :type ShortString) | ||
| (f/entry :schema_version SchemaVersion | ||
| :description "CTIM schema version for this entity.")) | ||
| (f/optional-entries | ||
| (f/entry :revision PosInt | ||
| :description "A monotonically increasing revision, incremented each time the object is changed.") | ||
| (f/entry :external_ids f/any-string-seq | ||
| (f/entry :external_ids (f/seq-of ShortString | ||
| :spec (pred/max-len default-collection-max-len)) | ||
| :description (str "It is used to store a list of external identifiers that can be linked to the " | ||
| "incident, providing a reliable and manageable way to correlate and group related " | ||
| "events across multiple data sources. It is especially useful in larger " | ||
|
|
@@ -209,7 +216,8 @@ | |
| "information can be shared among incident management systems. It can be used to " | ||
| "cross-reference with other external tools such as threat intelligence feeds and " | ||
| "vulnerability scanners.")) | ||
| (f/entry :external_references [ExternalReference] | ||
| (f/entry :external_references (f/seq-of ExternalReference | ||
| :spec (pred/max-len default-collection-max-len)) | ||
| :description (str "Specifies a list of external references which refers to non-CTIM " | ||
| "information.\n\n" | ||
| "Similar to `external_ids` field with major differences:\n\n" | ||
|
|
@@ -263,7 +271,7 @@ | |
| base-entity-entries | ||
| (f/optional-entries | ||
| (f/entry :id ID) | ||
| (f/entry :type f/any-str | ||
| (f/entry :type ShortString | ||
| :description "A valid entity type identifer") | ||
| (f/entry :schema_version CTIMSchemaVersion | ||
| :description "CTIM schema version for this entity.")))) | ||
|
|
@@ -322,20 +330,20 @@ | |
|
|
||
| (def-map-type Contributor | ||
| (f/optional-entries | ||
| (f/entry :role f/any-str | ||
| (f/entry :role ShortString | ||
| :description "Role played by this contributor.") | ||
| (f/entry :name f/any-str | ||
| (f/entry :name ShortString | ||
| :description "Name of this contributor.") | ||
| (f/entry :email f/any-str | ||
| (f/entry :email ShortString | ||
| :description "Email of this contributor.") | ||
| (f/entry :phone f/any-str | ||
| (f/entry :phone ShortString | ||
| :description "Telephone number of this contributor.") | ||
| (f/entry :organization f/any-str | ||
| (f/entry :organization ShortString | ||
| :description "Organization name of this contributor.") | ||
| (f/entry :date Time | ||
| :description (str "Description (bounding) of the timing of this " | ||
| "contributor's involvement.")) | ||
| (f/entry :contribution_location f/any-str | ||
| (f/entry :contribution_location ShortString | ||
| :description (str "information describing the location at which the " | ||
| "contributory activity occured"))) | ||
| :description "Person who contributed cyber observation data." | ||
|
|
@@ -350,10 +358,10 @@ | |
| (f/entry :confidence v/HighMedLow | ||
| :description (str "Specifies the level of confidence in the assertion " | ||
| "of the relationship between the two objects.")) | ||
| (f/entry :information_source f/any-str | ||
| (f/entry :information_source ShortString | ||
| :description (str "Specifies the source of the information about " | ||
| "the relationship between the two components.")) | ||
| (f/entry :relationship f/any-str))) | ||
| (f/entry :relationship ShortString))) | ||
| :description "Describes a related Identity" | ||
| :reference "[RelatedIdentityType](http://stixproject.github.io/data-model/1.2/stixCommon/RelatedIdentityType/)") | ||
|
|
||
|
|
@@ -618,12 +626,17 @@ | |
| :gen (cs/gen relation-types)) | ||
|
|
||
| (def-map-type ObservedRelation | ||
| [(f/entry :origin f/any-str) | ||
| [(f/entry :origin ShortString) | ||
| (f/entry :origin_uri URI | ||
| :required? false) | ||
| (f/entry :relation ObservableRelationType) | ||
| (f/entry :relation_info (f/map | ||
| [(f/entry f/any-keyword f/any)]) | ||
| [(f/entry f/any-keyword f/any)] | ||
| :spec (fn [m] | ||
| (let [actions (:actions m)] | ||
| (or (nil? actions) | ||
| (not (sequential? actions)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM -- Actions cap is bypassable: the limit only applies when |
||
| ((pred/max-len max-relation-actions) actions))))) | ||
| :required? false) | ||
| (f/entry :source Observable) | ||
| (f/entry :related Observable)] | ||
|
|
@@ -642,12 +655,12 @@ | |
| (f/entry :observables [Observable]) | ||
| (f/entry :observed_time ObservedTime)) | ||
| (f/optional-entries | ||
| (f/entry :os f/any-str))) | ||
| (f/entry :os ShortString))) | ||
| :description "Describes the target of the sighting and contains identifying observables for the target.") | ||
|
|
||
| (def scalar | ||
| (f/conditional | ||
| #(string? %) f/any-str | ||
| #(string? %) MedString | ||
| #(number? %) f/any-num | ||
| #(inst? %) f/any-inst | ||
| #(keyword? %) f/any-keyword | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| (:require [ctim.schemas.common :as c] | ||
| [ctim.schemas.relationship :as rel] | ||
| [ctim.schemas.vocabularies :as v] | ||
| [ctim.lib.predicates :as pred] | ||
| #?(:clj [flanders.core :as f :refer [def-entity-type def-map-type def-eq]] | ||
| :cljs [flanders.core :as f :refer-macros [def-entity-type def-map-type def-eq]]) | ||
| #?(:clj [clojure.test.check.generators :as gen]))) | ||
|
|
@@ -127,13 +128,15 @@ | |
| :description "metadata associated to the incident.") | ||
| (f/entry :scores IncidentScores | ||
| :description "Used to indicate the severity or impact score of the threat represented by the incident.") | ||
| (f/entry :categories [v/IncidentCategory] | ||
| (f/entry :categories (f/seq-of v/IncidentCategory | ||
| :spec (pred/max-len c/default-collection-max-len)) | ||
| :description "A set of categories for this incident.") | ||
| (f/entry :discovery_method v/DiscoveryMethod | ||
| :description "Identifies how the incident was discovered.") | ||
| (f/entry :intended_effect v/IntendedEffect | ||
| :description "Specifies the suspected intended effect of this incident") | ||
| (f/entry :assignees [c/ShortString] | ||
| (f/entry :assignees (f/seq-of c/ShortString | ||
| :spec (pred/max-len c/default-collection-max-len)) | ||
| :description "A set of owners assigned to this incident.") | ||
| (f/entry :detection_sources [c/MedString] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM -- Uncapped sibling: |
||
| :description "A set of sources that contributed threat detections to the incident.") | ||
|
|
@@ -164,13 +167,15 @@ | |
| "interpreted differently by different organizations or analysts. Therefore, it " | ||
| "should be used in conjunction with other intelligence attributes, such as the " | ||
| "`confidence` field, to provide a more comprehensive view of the incident.")) | ||
| (f/entry :tactics [c/ShortString] | ||
| (f/entry :tactics (f/seq-of c/ShortString | ||
| :spec (pred/max-len c/default-collection-max-len)) | ||
| :description (str "Represents the offensive techniques, approaches, or procedures that an adversary " | ||
| "may use to achieve their objectives during an attack. It helps in understanding " | ||
| "the intent and capabilities of the adversary and can be used to identify " | ||
| "indicators of attack (IoAs) or indicators of compromise (IoCs) that are " | ||
| "associated with the adversary's tactics.")) | ||
| (f/entry :techniques [c/ShortString] | ||
| (f/entry :techniques (f/seq-of c/ShortString | ||
| :spec (pred/max-len c/default-collection-max-len)) | ||
| :description (str "Represents the specific methods or actions used by an attacker " | ||
| "to carry out an offensive maneuver or achieve their goals.")) | ||
| (f/entry :short_id c/ShortString | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,33 +28,33 @@ | |
|
|
||
| (def-map-type ThreatBrainSpecification | ||
| [(f/entry :type ThreatBrainSpecificationType) | ||
| (f/entry :query f/any-str | ||
| (f/entry :query c/MedString | ||
| :required? false) | ||
| (f/entry :variables f/any-str-seq)] | ||
| (f/entry :variables (f/seq-of c/ShortString))] | ||
| :description "An indicator which runs in threatbrain...") | ||
|
|
||
| (def-eq SnortSpecificationType "Snort") | ||
|
|
||
| (def-map-type SnortSpecification | ||
| (f/required-entries | ||
| (f/entry :type SnortSpecificationType) | ||
| (f/entry :snort_sig f/any-str)) | ||
| (f/entry :snort_sig c/MedString)) | ||
| :description "An indicator which runs in snort...") | ||
|
|
||
| (def-eq SIOCSpecificationType "SIOC") | ||
|
|
||
| (def-map-type SIOCSpecification | ||
| (f/required-entries | ||
| (f/entry :type SIOCSpecificationType) | ||
| (f/entry :SIOC f/any-str)) | ||
| (f/entry :SIOC c/MedString)) | ||
| :description "An indicator which runs in snort...") | ||
|
|
||
| (def-eq OpenIOCSpecificationType "OpenIOC") | ||
|
|
||
| (def-map-type OpenIOCSpecification | ||
| (f/required-entries | ||
| (f/entry :type OpenIOCSpecificationType) | ||
| (f/entry :open_IOC f/any-str)) | ||
| (f/entry :open_IOC c/MedString)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH -- Bound likely too small for documented content: this field's docstring describes it as "an XML blob of an openIOC indicator," and OpenIOC XML documents routinely exceed 2048 chars, so |
||
| :description "An indicator which contains an XML blob of an openIOC indicator.") | ||
|
|
||
| (def-enum-type BooleanOperator | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL -- SNAPSHOT dependency on unreleased flanders:
1.1.1-SNAPSHOThas no flanders git tag, no GitHub release, and Clojars 404s for it. The:specsupport onSequenceOfType/SetOfType/MapTypethat this entire PR depends on exists only on flandersmaster, not in 1.1.0. Merging this tomastermakes the build non-reproducible (a SNAPSHOT is mutable and can be GC'd), blocks any stable ctim release, and leaves these constraints inert until flanders 1.1.1 ships. Release flanders 1.1.1 to Clojars and pin the released version before merge.