All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kodekutters.stix.Example1.scala Maven / Gradle / Ivy

//package com.kodekutters.stix
//
//import java.util.UUID
//
//import com.kodekutters.stix.Util.uuidPattern
//
//import scala.io.Source
//import play.api.libs.json.Json
//
//
///**
//  * a simple example
//  */
//object Example1 {
//  def main(args: Array[String]): Unit = {
//
////    val s = AttackPattern.`type` + "--d3aa88e2-c754-41e0-8ba6-4198a34aa0a2"
////    val s2 = "123--d3aa88e2-c754-41e0-8ba6-4198a34aa0a2"
////    println("result: "+Identifier.stringToIdentifierOption(s))
//
////    println("red: "+  TLPlevels.fromString("xxx"))
//
//
//    // read a STIX-2 bundle from a file threat-reports/
//    val jsondoc = Source.fromFile("./stix-files/testmitre.json").mkString
//    // create a bundle object from it
//    Json.fromJson[Bundle](Json.parse(jsondoc)).asOpt match {
//      case Some(bundle) =>
//        println("count: " + bundle.objects.length)
//      //  bundle.objects.foreach(sdo => println("sdo: " + sdo))
//        // get all attack pattern
//      //  val allAttacks = bundle.objects.filter(_.`type` == Report.`type`)
//      //  allAttacks.foreach(x => println("attack: " + x))
//        // convert them to json and print
//     //   allAttacks.foreach(x => println(Json.prettyPrint(Json.toJson(x))))
//
//        val bundlejson = Json.toJson(bundle)
//        println(Json.prettyPrint(bundlejson))
//
//      case None => println("invalid JSON")
//    }
//
//  }
//}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy