models.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * TraCINg-Server - Gathering and visualizing cyber incidents on the world
  3. *
  4. * Copyright 2013 Matthias Gazzari, Annemarie Mattmann, André Wolski
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var orm = require("orm");
  19. exports.initialize = function(db){
  20. // define structure for incidents in orm-layer and export the structure
  21. exports.Incident = db.define(
  22. "incident", {
  23. date: Date,
  24. sensortype: String,
  25. sensorname: String,
  26. source_ip: String,
  27. source_port: { type: "number", rational: false },
  28. destination_ip: String,
  29. destination_port: { type: "number", rational: false },
  30. type: { type: "number", rational: false },
  31. log: String,
  32. md5sum: String,
  33. authorized: Boolean,
  34. source_country: String,
  35. source_cc: String,
  36. //source_region: String,
  37. source_city: String,
  38. source_latitude: { type: "number", rational: true },
  39. source_longitude: { type: "number", rational: true },
  40. destination_country: String,
  41. destination_cc: String,
  42. //destination_region: String,
  43. destination_city: String,
  44. destination_latitude: { type: "number", rational: true },
  45. destination_longitude: { type: "number", rational: true },
  46. // data: Object // JSON encoded
  47. },
  48. {
  49. methods: {
  50. /*
  51. fullName: function () {
  52. return this.name + ' ' + this.surname;
  53. }
  54. */
  55. },
  56. validations: {
  57. //age: orm.validators.rangeNumber(18, undefined, "under-age")
  58. }
  59. }
  60. );
  61. };