CheckGroup.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. /**
  3. * A group of security checks.
  4. * @interface
  5. * @memberof module:SecurityCheck
  6. */
  7. class CheckGroup {
  8. constructor() {
  9. this._name = this.setName();
  10. this._checks = this.setChecks();
  11. }
  12. /**
  13. * The security check group name; to be overridden by child class.
  14. */
  15. setName() {
  16. throw `Check group has no name.`;
  17. }
  18. name() {
  19. return this._name;
  20. }
  21. /**
  22. * The security checks; to be overridden by child class.
  23. */
  24. setChecks() {
  25. throw `Check group has no checks.`;
  26. }
  27. checks() {
  28. return this._checks;
  29. }
  30. /**
  31. * Runs all checks.
  32. */
  33. async run() {
  34. for (const check of this._checks) {
  35. check.run();
  36. }
  37. }
  38. }
  39. module.exports = CheckGroup;
  40. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDaGVja0dyb3VwIiwiY29uc3RydWN0b3IiLCJfbmFtZSIsInNldE5hbWUiLCJfY2hlY2tzIiwic2V0Q2hlY2tzIiwibmFtZSIsImNoZWNrcyIsInJ1biIsImNoZWNrIiwibW9kdWxlIiwiZXhwb3J0cyJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9TZWN1cml0eS9DaGVja0dyb3VwLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQSBncm91cCBvZiBzZWN1cml0eSBjaGVja3MuXG4gKiBAaW50ZXJmYWNlXG4gKiBAbWVtYmVyb2YgbW9kdWxlOlNlY3VyaXR5Q2hlY2tcbiAqL1xuY2xhc3MgQ2hlY2tHcm91cCB7XG4gIGNvbnN0cnVjdG9yKCkge1xuICAgIHRoaXMuX25hbWUgPSB0aGlzLnNldE5hbWUoKTtcbiAgICB0aGlzLl9jaGVja3MgPSB0aGlzLnNldENoZWNrcygpO1xuICB9XG5cbiAgLyoqXG4gICAqIFRoZSBzZWN1cml0eSBjaGVjayBncm91cCBuYW1lOyB0byBiZSBv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