diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9308b7f2..0cd9f4a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,6 @@ on: branches: - master pull_request: - schedule: - # 12:00AM on the first of every month - - cron: "0 0 1 * *" jobs: setup: diff --git a/README.md b/README.md index 4e2eaa21..de4c54b4 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ lein doc ## Releases ```clojure +# Patch version releases (minor and major increments require a manual edit of version). +# Expect this task to modify project files and deploy to Clojars. +# See `release-tasks` in project.clj for details. +lein release + # snapshot release lein deploy diff --git a/dev/ctim/change_schema_version.clj b/dev/ctim/change_schema_version.clj new file mode 100644 index 00000000..f03ce41f --- /dev/null +++ b/dev/ctim/change_schema_version.clj @@ -0,0 +1,5 @@ +(ns ctim.change-schema-version) + +(defn -main + [version] + (spit "./resources/version.txt" version)) diff --git a/doc/json/actor.json b/doc/json/actor.json index 7a4ed811..e2203ac8 100644 --- a/doc/json/actor.json +++ b/doc/json/actor.json @@ -26,7 +26,7 @@ "motivation" : "Ego", "planning_and_operational_support" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "sophistication" : "Aspirant", "source" : "string", diff --git a/doc/json/asset.json b/doc/json/asset.json index 2ce133fa..d2b2a570 100644 --- a/doc/json/asset.json +++ b/doc/json/asset.json @@ -12,7 +12,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/asset_mapping.json b/doc/json/asset_mapping.json index a42db8ab..37dbbd28 100644 --- a/doc/json/asset_mapping.json +++ b/doc/json/asset_mapping.json @@ -17,7 +17,7 @@ "value" : "1.2.3.4" }, "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "specificity" : "Low", diff --git a/doc/json/asset_properties.json b/doc/json/asset_properties.json index d0da4a9c..7c555343 100644 --- a/doc/json/asset_properties.json +++ b/doc/json/asset_properties.json @@ -15,7 +15,7 @@ "value" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", diff --git a/doc/json/attack_pattern.json b/doc/json/attack_pattern.json index 2f447af4..dfbcd34b 100644 --- a/doc/json/attack_pattern.json +++ b/doc/json/attack_pattern.json @@ -16,7 +16,7 @@ } ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/bundle.json b/doc/json/bundle.json index 1766e0f1..8a13076a 100644 --- a/doc/json/bundle.json +++ b/doc/json/bundle.json @@ -28,7 +28,7 @@ "motivation" : "Ego", "planning_and_operational_support" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "sophistication" : "Aspirant", "source" : "string", @@ -62,7 +62,7 @@ "value" : "1.2.3.4" }, "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "specificity" : "Low", @@ -92,7 +92,7 @@ "value" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -119,7 +119,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -151,7 +151,7 @@ } ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -185,7 +185,7 @@ "language" : "string", "names" : [ "string" ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -259,7 +259,7 @@ "source" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -297,7 +297,7 @@ "revision" : 10, "row_count" : 10, "rows" : [ [ "anything" ] ], - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -335,7 +335,7 @@ "language" : "string", "reason" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -366,7 +366,7 @@ }, "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -410,7 +410,7 @@ }, "promotion_method" : "Automated", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "scores" : { "asset" : 10.0 }, @@ -453,7 +453,7 @@ "negate" : true, "producer" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "short_description" : "string", "source" : "string", @@ -502,7 +502,7 @@ "reason" : "string", "reason_uri" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "source" : "string", "source_uri" : "string", @@ -535,7 +535,7 @@ "labels" : [ "adware" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -565,7 +565,7 @@ "entity_type" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -587,7 +587,7 @@ "language" : "string", "relationship_type" : "attributed-to", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_ref" : "string", @@ -599,7 +599,7 @@ "type" : "relationship" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "sighting_refs" : [ "string" ], "sightings" : [ { @@ -867,7 +867,7 @@ } ], "resolution" : "detected", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "sensor" : "endpoint", "sensor_coordinates" : { "observables" : [ { @@ -914,7 +914,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -960,7 +960,7 @@ "labels" : [ "credential-exploitation" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -1101,7 +1101,7 @@ "last_modified_date" : "2016-01-01T01:01:01.000Z", "published_date" : "2016-01-01T01:01:01.000Z", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -1182,7 +1182,7 @@ "strategy" : "Attack Surface Reduction" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/campaign.json b/doc/json/campaign.json index b69baccd..205b7e8f 100644 --- a/doc/json/campaign.json +++ b/doc/json/campaign.json @@ -19,7 +19,7 @@ "language" : "string", "names" : [ "string" ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/casebook.json b/doc/json/casebook.json index 35152c6a..cd962be9 100644 --- a/doc/json/casebook.json +++ b/doc/json/casebook.json @@ -29,7 +29,7 @@ "motivation" : "Ego", "planning_and_operational_support" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "sophistication" : "Aspirant", "source" : "string", @@ -63,7 +63,7 @@ "value" : "1.2.3.4" }, "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "specificity" : "Low", @@ -93,7 +93,7 @@ "value" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -120,7 +120,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -152,7 +152,7 @@ } ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -186,7 +186,7 @@ "language" : "string", "names" : [ "string" ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -260,7 +260,7 @@ "source" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -298,7 +298,7 @@ "revision" : 10, "row_count" : 10, "rows" : [ [ "anything" ] ], - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -336,7 +336,7 @@ "language" : "string", "reason" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -367,7 +367,7 @@ }, "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -411,7 +411,7 @@ }, "promotion_method" : "Automated", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "scores" : { "asset" : 10.0 }, @@ -454,7 +454,7 @@ "negate" : true, "producer" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "short_description" : "string", "source" : "string", @@ -503,7 +503,7 @@ "reason" : "string", "reason_uri" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "source" : "string", "source_uri" : "string", @@ -536,7 +536,7 @@ "labels" : [ "adware" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -566,7 +566,7 @@ "entity_type" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", @@ -588,7 +588,7 @@ "language" : "string", "relationship_type" : "attributed-to", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_ref" : "string", @@ -600,7 +600,7 @@ "type" : "relationship" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "sighting_refs" : [ "string" ], "sightings" : [ { @@ -868,7 +868,7 @@ } ], "resolution" : "detected", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "sensor" : "endpoint", "sensor_coordinates" : { "observables" : [ { @@ -915,7 +915,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -961,7 +961,7 @@ "labels" : [ "credential-exploitation" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -1102,7 +1102,7 @@ "last_modified_date" : "2016-01-01T01:01:01.000Z", "published_date" : "2016-01-01T01:01:01.000Z", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -1183,7 +1183,7 @@ "strategy" : "Attack Surface Reduction" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", @@ -1214,7 +1214,7 @@ "value" : "1.2.3.4" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/coa.json b/doc/json/coa.json index 1730f725..294e8e55 100644 --- a/doc/json/coa.json +++ b/doc/json/coa.json @@ -57,7 +57,7 @@ "source" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/feedback.json b/doc/json/feedback.json index 7b97005c..41d1b288 100644 --- a/doc/json/feedback.json +++ b/doc/json/feedback.json @@ -13,7 +13,7 @@ "language" : "string", "reason" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", diff --git a/doc/json/incident.json b/doc/json/incident.json index fab83a63..e9ba2958 100644 --- a/doc/json/incident.json +++ b/doc/json/incident.json @@ -30,7 +30,7 @@ }, "promotion_method" : "Automated", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "scores" : { "asset" : 10.0 }, diff --git a/doc/json/indicator.json b/doc/json/indicator.json index 1741ddfe..e4aa7e16 100644 --- a/doc/json/indicator.json +++ b/doc/json/indicator.json @@ -24,7 +24,7 @@ "negate" : true, "producer" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "short_description" : "string", "source" : "string", diff --git a/doc/json/judgement.json b/doc/json/judgement.json index 840c0ac7..dbed499e 100644 --- a/doc/json/judgement.json +++ b/doc/json/judgement.json @@ -20,7 +20,7 @@ "reason" : "string", "reason_uri" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "severity" : "Critical", "source" : "string", "source_uri" : "string", diff --git a/doc/json/malware.json b/doc/json/malware.json index 68d56ca2..77c1309f 100644 --- a/doc/json/malware.json +++ b/doc/json/malware.json @@ -17,7 +17,7 @@ "labels" : [ "adware" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/note.json b/doc/json/note.json index e37b60c6..cb0d4b67 100644 --- a/doc/json/note.json +++ b/doc/json/note.json @@ -17,7 +17,7 @@ "entity_type" : "string" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "source" : "string", "source_uri" : "string", "timestamp" : "2016-01-01T01:01:01.000Z", diff --git a/doc/json/relationship.json b/doc/json/relationship.json index bd6aca80..384c0885 100644 --- a/doc/json/relationship.json +++ b/doc/json/relationship.json @@ -12,7 +12,7 @@ "language" : "string", "relationship_type" : "attributed-to", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_ref" : "string", diff --git a/doc/json/sighting.json b/doc/json/sighting.json index f3712573..6fe26109 100644 --- a/doc/json/sighting.json +++ b/doc/json/sighting.json @@ -263,7 +263,7 @@ } ], "resolution" : "detected", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "sensor" : "endpoint", "sensor_coordinates" : { "observables" : [ { diff --git a/doc/json/target_record.json b/doc/json/target_record.json index 28d084d7..7d17ee64 100644 --- a/doc/json/target_record.json +++ b/doc/json/target_record.json @@ -11,7 +11,7 @@ "id" : "string", "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/tool.json b/doc/json/tool.json index e7859992..3b5b1b16 100644 --- a/doc/json/tool.json +++ b/doc/json/tool.json @@ -16,7 +16,7 @@ "labels" : [ "credential-exploitation" ], "language" : "string", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/vulnerability.json b/doc/json/vulnerability.json index 9212f124..022164a9 100644 --- a/doc/json/vulnerability.json +++ b/doc/json/vulnerability.json @@ -108,7 +108,7 @@ "last_modified_date" : "2016-01-01T01:01:01.000Z", "published_date" : "2016-01-01T01:01:01.000Z", "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/doc/json/weakness.json b/doc/json/weakness.json index 52885eab..e15fa36e 100644 --- a/doc/json/weakness.json +++ b/doc/json/weakness.json @@ -68,7 +68,7 @@ "strategy" : "Attack Surface Reduction" } ], "revision" : 10, - "schema_version" : "1.3.25", + "schema_version" : "1.3.25-SNAPSHOT", "short_description" : "string", "source" : "string", "source_uri" : "string", diff --git a/project.clj b/project.clj index 9ce619b0..2b4dd2d8 100644 --- a/project.clj +++ b/project.clj @@ -19,7 +19,7 @@ [kovacnica/clojure.network.ip "0.1.3"]] :uberjar-name "ctim.jar" - :resource-paths ["doc"] + :resource-paths ["doc" "resources"] :plugins [[lein-cljsbuild "1.1.7"] [com.google.guava/guava "20.0"] ;resolve internal conflict in `lein-doo` @@ -38,11 +38,13 @@ ;; please commit it and try again ["vcs" "assert-committed"] ["change" "version" "leiningen.release/bump-version" "release"] + ["sync-schema-version"] ;; will fail if project.clj doesn't already have -SNAPSHOT version ["vcs" "commit"] ["vcs" "tag" "--no-sign"] ["deploy" "clojars"] ["change" "version" "leiningen.release/bump-version"] + ["sync-schema-version"] ["vcs" "commit"] ;; fails if no upstream branch is defined ;; if it fails at this point you can complete the release using: @@ -51,7 +53,11 @@ :aliases {"doc" ^{:doc "Generate documentation"} ["run" "-m" "ctim.document"] "docs" ^{:doc "Generate documentation"} ["doc"] - "gen" ^{:doc "Generate an example"} ["run" "-m" "ctim.generate"]} + "gen" ^{:doc "Generate an example"} ["run" "-m" "ctim.generate"] + "sync-schema-version" ^{:doc "Updates the CTIM schema version to match the project version."} ["run" + "-m" + "ctim.change-schema-version" + :project/version]} :cljsbuild {:builds {:node {:source-paths ["src" "test"] :compiler {:output-to "target/tests.js" @@ -75,4 +81,5 @@ [com.google.errorprone/error_prone_annotations "2.1.3"] ;;https://clojure.atlassian.net/browse/CLJS-3047 [com.google.code.findbugs/jsr305 "3.0.2"] - [org.clojure/clojurescript "1.10.597"]]}}) + [org.clojure/clojurescript "1.10.597"]]} + :dev {:source-paths ["dev"]}}) diff --git a/resources/ctim/version.txt b/resources/ctim/version.txt new file mode 100644 index 00000000..3ef6f64f --- /dev/null +++ b/resources/ctim/version.txt @@ -0,0 +1 @@ +1.3.25-SNAPSHOT \ No newline at end of file diff --git a/script/release.sh b/script/release.sh deleted file mode 100755 index a1c085b5..00000000 --- a/script/release.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -xe -lein release :patch diff --git a/src/ctim/examples/incidents.cljc b/src/ctim/examples/incidents.cljc index aaf591ec..ecbaf1dc 100644 --- a/src/ctim/examples/incidents.cljc +++ b/src/ctim/examples/incidents.cljc @@ -37,7 +37,8 @@ :remediated #inst "2016-02-11T00:40:48.212-00:00" :reported #inst "2016-02-11T00:40:48.212-00:00" :closed #inst "2016-02-11T00:40:48.212-00:00" - :rejected #inst "2016-02-11T00:40:48.212-00:00"} + :rejected #inst "2016-02-11T00:40:48.212-00:00" + :contained #inst "2016-02-11T00:40:48.212-00:00"} :discovery_method "Log Review" :promotion_method "Manual" :intended_effect "Extortion" diff --git a/src/ctim/schemas/common.cljc b/src/ctim/schemas/common.cljc index f1daccdd..388b55ab 100644 --- a/src/ctim/schemas/common.cljc +++ b/src/ctim/schemas/common.cljc @@ -1,7 +1,11 @@ (ns ctim.schemas.common (:refer-clojure :exclude [ref uri?]) + #?(:cljs + (:require-macros [ctim.version :refer [ctim-version]])) (:require [clj-momo.lib.clj-time.coerce :refer [to-long]] + #?(:clj [clojure.java.io :as io]) [clojure.set :refer [map-invert]] + [clojure.string :as str] #?(:clj [clojure.spec.alpha :as cs] :cljs [cljs.spec.alpha :as cs]) [clojure.zip :as z] @@ -10,6 +14,7 @@ #?(:clj [ctim.lib.generators :as gen]) [ctim.lib.predicates :as pred] [ctim.schemas.vocabularies :as v] + #?(:clj [ctim.version :refer [ctim-version]]) #?(:clj [flanders.core :as f :refer [def-map-type def-enum-type def-eq]] @@ -17,15 +22,15 @@ def-enum-type def-eq]]) [flanders.navigation :as fn] - [flanders.predicates :as fp] - [clojure.string :as str])) + [flanders.predicates :as fp])) -(def ctim-schema-version "1.3.25") + +(def ctim-schema-version (ctim-version)) (def-eq CTIMSchemaVersion ctim-schema-version) (cs/def ::ctim-schema-version - #(re-matches #"\w+.\w+\.\w+" %)) + #(re-matches #"\w+.\w+\.\w+(-SNAPSHOT)?" %)) (def SchemaVersion (f/str diff --git a/src/ctim/version.clj b/src/ctim/version.clj new file mode 100644 index 00000000..be7ac12d --- /dev/null +++ b/src/ctim/version.clj @@ -0,0 +1,8 @@ +(ns ctim.version + (:require [clojure.java.io :as io])) + +(defmacro ctim-version + "This is a macro to support cljs compile-time inlining of the version string + from the JVM resource." + [] + (slurp (io/resource "ctim/version.txt"))) diff --git a/test/ctim/schemas/common_test.cljc b/test/ctim/schemas/common_test.cljc index da6be43f..b308da5f 100644 --- a/test/ctim/schemas/common_test.cljc +++ b/test/ctim/schemas/common_test.cljc @@ -1,8 +1,10 @@ (ns ctim.schemas.common-test (:refer-clojure :exclude [ref uri?]) - (:require [ctim.schemas.common :as sut] - [flanders.schema :as fs] - [clojure.test :refer [deftest is]])) + (:require + [clojure.java.io :as io] + [clojure.test :refer [deftest is testing]] + [ctim.schemas.common :as sut] + [flanders.schema :as fs])) (defn- ->swagger [dll] (:json-schema (meta (fs/->schema dll)))) @@ -10,3 +12,18 @@ (is (= {:example {:value "1.2.3.4", :type "ip"} :description "A simple, atomic value which has a consistent identity, and is stable enough to be attributed an intent or nature. This is the classic 'indicator' which might appear in a data feed of bad IPs, or bad Domains. These do not exist as objects within the CTIA storage model, so you never create an observable."} (->swagger sut/Observable)))) + +(defn lein-project-version + [] + (let [properties (with-open [pom-properties-reader (io/reader (io/resource "META-INF/maven/threatgrid/ctim/pom.properties"))] + (doto (java.util.Properties.) + (.load pom-properties-reader)))] + (if-let [ver (get properties "version")] + ver + (throw (ex-info "Unable to resolve ctim version" {}))))) + +(deftest version-test + (testing "The lein project version and ctim schema version are in sync." + (is (re-matches #"[\d]+\.[\d]+\.[\d]+.*?" sut/ctim-schema-version) + "Version follows the expected semantic versioning pattern.") + (is (= (lein-project-version) sut/ctim-schema-version))))