| 60 | } |
| 61 | |
| 62 | fn write_graphql_policy(host: &str, port: u16) -> Result<NamedTempFile, String> { |
| 63 | let mut file = NamedTempFile::new().map_err(|e| format!("create temp policy file: {e}"))?; |
| 64 | let policy = format!( |
| 65 | r#"version: 1 |
| 66 | |
| 67 | filesystem_policy: |
| 68 | include_workdir: true |
| 69 | read_only: |
| 70 | - /usr |
| 71 | - /lib |
| 72 | - /proc |
| 73 | - /dev/urandom |
| 74 | - /app |
| 75 | - /etc |
| 76 | - /var/log |
| 77 | read_write: |
| 78 | - /sandbox |
| 79 | - /tmp |
| 80 | - /dev/null |
| 81 | |
| 82 | landlock: |
| 83 | compatibility: best_effort |
| 84 | |
| 85 | process: |
| 86 | run_as_user: sandbox |
| 87 | run_as_group: sandbox |
| 88 | |
| 89 | network_policies: |
| 90 | test_graphql_l7: |
| 91 | name: test_graphql_l7 |
| 92 | endpoints: |
| 93 | - host: {host} |
| 94 | port: {port} |
| 95 | protocol: graphql |
| 96 | enforcement: enforce |
| 97 | persisted_queries: allow_registered |
| 98 | graphql_persisted_queries: |
| 99 | abc123: |
| 100 | operation_type: query |
| 101 | operation_name: Viewer |
| 102 | fields: [viewer] |
| 103 | allowed_ips: |
| 104 | - "10.0.0.0/8" |
| 105 | - "172.0.0.0/8" |
| 106 | - "192.168.0.0/16" |
| 107 | - "fc00::/7" |
| 108 | rules: |
| 109 | - allow: |
| 110 | operation_type: query |
| 111 | fields: [viewer] |
| 112 | - allow: |
| 113 | operation_type: mutation |
| 114 | fields: [createIssue] |
| 115 | deny_rules: |
| 116 | - operation_type: mutation |
| 117 | fields: [deleteRepository] |
| 118 | binaries: |
| 119 | - path: /usr/bin/python* |