build-cloudmounter-rules.ts 941 B

12345678910111213141516171819202122232425262728
  1. import { DOMAINS, PROCESS_NAMES } from '../Source/non_ip/cloudmounter';
  2. import { SHARED_DESCRIPTION } from './lib/constants';
  3. import { task } from './trace';
  4. import { RulesetOutput } from './lib/create-file-new';
  5. export const buildCloudMounterRules = task(require.main === module, __filename)(async (span) => {
  6. // AND,((SRC-IP,192.168.1.110), (DOMAIN, example.com))
  7. const results = DOMAINS.flatMap(domain => {
  8. return PROCESS_NAMES.flatMap(process => [
  9. `AND,((${domain}),(PROCESS-NAME,${process}))`,
  10. ...[
  11. '10.0.0.0/8',
  12. // '127.0.0.0/8',
  13. '172.16.0.0/12',
  14. '192.168.0.0/16'
  15. ].map(cidr => `AND,((${domain}),(SRC-IP,${cidr}))`)
  16. ]);
  17. });
  18. const description = SHARED_DESCRIPTION;
  19. return new RulesetOutput(span, 'cloudmounter', 'non_ip')
  20. .withTitle('Sukka\'s Ruleset - CloudMounter / RaiDrive')
  21. .withDescription(description)
  22. .addFromRuleset(results)
  23. .write();
  24. });