<commit_before>(ns ctia.http.handler
  (:require [ctia.schemas.actor :refer [NewActor StoredActor realize-actor]]
            [ctia.schemas.campaign :refer [NewCampaign StoredCampaign realize-campaign]]
            [ctia.schemas.coa :refer [NewCOA StoredCOA realize-coa]]
            [ctia.schemas.common
             :refer [DispositionName DispositionNumber Time VersionInfo]]
            [ctia.schemas.exploit-target
             :refer [NewExploitTarget StoredExploitTarget realize-exploit-target]]
            [ctia.schemas.incident :refer [NewIncident StoredIncident realize-incident]]
            [ctia.schemas.indicator
             :refer [NewIndicator StoredIndicator generalize-indicator realize-indicator]]
            [ctia.schemas.feedback :refer [NewFeedback StoredFeedback realize-feedback]]
            [ctia.schemas.judgement :refer [NewJudgement StoredJudgement realize-judgement]]
            [ctia.schemas.relationships :as rel]
            [ctia.schemas.sighting :refer [NewSighting StoredSighting realize-sighting]]
            [ctia.schemas.ttp :refer [NewTTP StoredTTP realize-ttp]]
            [ctia.schemas.vocabularies :refer [ObservableType]]
            [ctia.schemas.verdict :refer [Verdict]]
            [ctia.events.schemas :refer [ModelEventBase]]
            [ctia.events :refer [recent-events]]
            [ctia.store :refer :all]
            [ctia.flows.crud :as flows]
            [ctia.flows.hooks :as hooks]
            [compojure.api.sweet :refer :all]
            [ring.middleware.format :refer [wrap-restful-format]]
            [ring.middleware.params :as params]
            [ring.util.http-response :refer :all]
            [schema.core :as s]
            [ctia.schemas.relationships :as rel]
            [ctia.http.middleware.auth :as auth]
            [ctia.http.routes.documentation :refer [documentation-routes]]))

(def JudgementSort
  "A sort ordering"
  (s/enum "disposition" "timestamp" "priority" "severity" "confidence"))

(def IndicatorSort
  "A sort ordering"
  (s/enum "title" "timestamp"))

(def RelationSort
  "A sort ordering"
  (s/enum "relation" "related" "related_type" "timestamp"))

(def SortOrder
  (s/enum "asc" "desc"))

(def api-description
  "A Threat Intelligence API service

  This API provides a mechanism for making Judgements on the Disposition
  of Observables, which are then distilled into a final Verdict.  A
  Disposition is a statement regarding the malicious, or otherwise,
  nature of an Observable.

  The Judgements can be grouped into Indicators, which can be associated
  with Campaigns, Actors and TTPs.  Feedback can be given on specific
  Judgements, indicating agreement or disagreement, or clarification.

  When an Observable with a malicious Verdict is seen, it can be recorded as
  a Sighting, and the Relations that Observable had with other Observables can
  be recorded as well.

  We support a pre-defined set of Observable Types.  Each Observable Type has a
  specific form of natural identifier, its ID, which is almost always
  the default way it it represented when observed in the wild.

  * Ipv4/IPv6  -- 192.168.1.1
  * Domain/Hostname -- foo.com, www.bar.com
  * SHA256  -- the sha256 checksum of a file, or other data blob
  * MD5 -- the md5 checksum of a file, or other data blob
  * SHA1 -- the sha1 checksum of a file, or other data blob
  * URL -- A minimal form of the URL

  The Verdict is derived from all of the Judgements on that Observable which
  have not yet expired.  The highest priority Judgement becomes the
  active verdict.  If there is more than one Judgement with that
  priority, than Clean disposition has priority over all others, then
  Malicious disposition, and so on down to Unknown.

  <a href='/doc/data_structures.md'>Data structures documentation</a>")



(defapi api-handler
  {:swagger {:ui "/"
             :spec "/swagger.json"
             :data {:info {:title "Cisco Threat Intel API "
                           :license {:name "All Rights Reserved",
                                     :url ""}
                           :contact {:name "Cisco Security Business Group -- Advanced Threat "
                                     :url "http://intel.threatgrid.cisco.com/support"
                                     :email "<EMAIL>"}
                           :description api-description}
                    :tags [{:name "threat", :description "Threat Intelligence"}]}}}

  documentation-routes

  (context "/ctia" []
    (context "/version" []
      :tags ["version"]
      (GET "/" []
        :return VersionInfo
        :summary "API version details"
        (ok {:base "/ctia"
             :version "0.1"
             :beta true
             :supported_features []})))

    (context "/actor" []
      :tags ["Actor"]
      (POST "/" []
        :return StoredActor
        :body [actor NewActor {:description "a new Actor"}]
        :header-params [api_key :- s/Str]
        :summary "Adds a new Actor"
        :capabilities #{:create-actor :admin}
        :login login<commit_msg>Update link to API info, to point to the repo<commit_after>(ns ctia.http.handler
  (:require [ctia.schemas.actor :refer [NewActor StoredActor realize-actor]]
            [ctia.schemas.campaign :refer [NewCampaign StoredCampaign realize-campaign]]
            [ctia.schemas.coa :refer [NewCOA StoredCOA realize-coa]]
            [ctia.schemas.common
             :refer [DispositionName DispositionNumber Time VersionInfo]]
            [ctia.schemas.exploit-target
             :refer [NewExploitTarget StoredExploitTarget realize-exploit-target]]
            [ctia.schemas.incident :refer [NewIncident StoredIncident realize-incident]]
            [ctia.schemas.indicator
             :refer [NewIndicator StoredIndicator generalize-indicator realize-indicator]]
            [ctia.schemas.feedback :refer [NewFeedback StoredFeedback realize-feedback]]
            [ctia.schemas.judgement :refer [NewJudgement StoredJudgement realize-judgement]]
            [ctia.schemas.relationships :as rel]
            [ctia.schemas.sighting :refer [NewSighting StoredSighting realize-sighting]]
            [ctia.schemas.ttp :refer [NewTTP StoredTTP realize-ttp]]
            [ctia.schemas.vocabularies :refer [ObservableType]]
            [ctia.schemas.verdict :refer [Verdict]]
            [ctia.events.schemas :refer [ModelEventBase]]
            [ctia.events :refer [recent-events]]
            [ctia.store :refer :all]
            [ctia.flows.crud :as flows]
            [ctia.flows.hooks :as hooks]
            [compojure.api.sweet :refer :all]
            [ring.middleware.format :refer [wrap-restful-format]]
            [ring.middleware.params :as params]
            [ring.util.http-response :refer :all]
            [schema.core :as s]
            [ctia.schemas.relationships :as rel]
            [ctia.http.middleware.auth :as auth]
            [ctia.http.routes.documentation :refer [documentation-routes]]))

(def JudgementSort
  "A sort ordering"
  (s/enum "disposition" "timestamp" "priority" "severity" "confidence"))

(def IndicatorSort
  "A sort ordering"
  (s/enum "title" "timestamp"))

(def RelationSort
  "A sort ordering"
  (s/enum "relation" "related" "related_type" "timestamp"))

(def SortOrder
  (s/enum "asc" "desc"))

(def api-description
  "A Threat Intelligence API service

  This API provides a mechanism for making Judgements on the Disposition
  of Observables, which are then distilled into a final Verdict.  A
  Disposition is a statement regarding the malicious, or otherwise,
  nature of an Observable.

  The Judgements can be grouped into Indicators, which can be associated
  with Campaigns, Actors and TTPs.  Feedback can be given on specific
  Judgements, indicating agreement or disagreement, or clarification.

  When an Observable with a malicious Verdict is seen, it can be recorded as
  a Sighting, and the Relations that Observable had with other Observables can
  be recorded as well.

  We support a pre-defined set of Observable Types.  Each Observable Type has a
  specific form of natural identifier, its ID, which is almost always
  the default way it it represented when observed in the wild.

  * Ipv4/IPv6  -- 192.168.1.1
  * Domain/Hostname -- foo.com, www.bar.com
  * SHA256  -- the sha256 checksum of a file, or other data blob
  * MD5 -- the md5 checksum of a file, or other data blob
  * SHA1 -- the sha1 checksum of a file, or other data blob
  * URL -- A minimal form of the URL

  The Verdict is derived from all of the Judgements on that Observable which
  have not yet expired.  The highest priority Judgement becomes the
  active verdict.  If there is more than one Judgement with that
  priority, than Clean disposition has priority over all others, then
  Malicious disposition, and so on down to Unknown.

  <a href='/doc/data_structures.md'>Data structures documentation</a>")



(defapi api-handler
  {:swagger {:ui "/"
             :spec "/swagger.json"
             :data {:info {:title "Cisco Threat Intel API "
                           :license {:name "All Rights Reserved",
                                     :url ""}
                           :contact {:name "Cisco Security Business Group -- Advanced Threat "
                                     :url "http://github.com/threatgrid/ctia"
                                     :email "<EMAIL>"}
                           :description api-description}
                    :tags [{:name "threat", :description "Threat Intelligence"}]}}}

  documentation-routes

  (context "/ctia" []
    (context "/version" []
      :tags ["version"]
      (GET "/" []
        :return VersionInfo
        :summary "API version details"
        (ok {:base "/ctia"
             :version "0.1"
             :beta true
             :supported_features []})))

    (context "/actor" []
      :tags ["Actor"]
      (POST "/" []
        :return StoredActor
        :body [actor NewActor {:description "a new Actor"}]
        :header-params [api_key :- s/Str]
        :summary "Adds a new Actor"
        :capabilities #{:create-actor :admin}
        :login login
{'fraction_non_alphanumeric': 0.09586056644880174, 'fraction_numerical': 0.004357298474945534, 'mean_word_length': 2.445581712726032, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7557065', 'n_tokens_mistral': 2973, 'n_tokens_neox': 2798, 'n_words': 942}