@digital-agora/friday-google-cloud 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/bin/friday-google-cloud.js +16 -0
- package/conventions/cloud-run.yaml +10 -0
- package/conventions/config-secrets.yaml +7 -0
- package/conventions/firestore-data.yaml +22 -0
- package/conventions/firestore-rules.yaml +23 -0
- package/conventions/gcp-iam.yaml +13 -0
- package/conventions/testing.yaml +7 -0
- package/package.json +26 -3
- package/personas/architect.yaml +2 -0
- package/personas/backend-engineer.yaml +2 -0
- package/personas/devops-engineer.yaml +2 -0
- package/personas/qa-engineer.yaml +2 -0
- package/personas/security-steward.yaml +5 -0
- package/specialization.yaml +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 digital-agora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @digital-agora/friday-google-cloud
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Google Cloud's specialization of [Friday](https://github.com/Digital-Agora/friday#readme): rules
|
|
4
|
+
that hold for any project on Google Cloud and Firebase, on top of Friday's generic pack. Each rule
|
|
5
|
+
cites Google's documentation, and the specialization's rules win over Friday's (decision 41).
|
|
6
|
+
MIT-licensed, published to npmjs.com and GitHub Packages (decision 53).
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npx -y @digital-agora/friday-google-cloud install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
That is `friday install --with @digital-agora/friday-google-cloud`; every friday command that
|
|
13
|
+
takes `--with` (validate, build, bundle, install, list, graph) gets it.
|
|
14
|
+
|
|
15
|
+
| Convention | What it says |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `firestore-rules` | Rules start deny-all; `match /{path=**}/private/{doc}` has no client access; an allow anywhere wins, so no recursive read wildcard over a tree with `private/`; each private path has a test that a client read and write are refused; public writes need App Check |
|
|
18
|
+
| `firestore-data` | Rules grant whole documents, so protected fields live only in `<parent>/private/<doc>`; server code bypasses rules, so database roles go only to the accounts that need them; no protected value in a document id or path; exports contain private documents; the database location is chosen once |
|
|
19
|
+
| `gcp-iam` | One user-managed service account per service, function codebase and job, never the default one; no service account keys, Workload Identity Federation for CI |
|
|
20
|
+
| `cloud-run` | A public service is deliberate and verifies every token itself |
|
|
21
|
+
| `config-secrets` (patch) | Secrets in Secret Manager, read by the workload's own account or one Cloud Build step |
|
|
22
|
+
| `testing` (patch) | The emulators run with `demo-` project ids |
|
|
23
|
+
|
|
24
|
+
It also sets the integration level of the test pyramid to the Firebase emulators and keeps
|
|
25
|
+
`emulators:exec` and `emulators:start` out of task loops.
|
|
26
|
+
|
|
27
|
+
## Build on it
|
|
28
|
+
|
|
29
|
+
A project specialization extends it, so installing the project's specialization brings these rules
|
|
30
|
+
first and the project's win over them (decision 53):
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
# specialization.yaml
|
|
34
|
+
id: acme
|
|
35
|
+
name: Acme
|
|
36
|
+
extends: ["@digital-agora/friday-google-cloud"]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
List `@digital-agora/friday-google-cloud` in the project specialization's `dependencies`, or give
|
|
40
|
+
a folder path. A project's own `.friday/` can extend it the same way.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// friday-google-cloud: Friday's CLI with the Google Cloud specialization applied (decision 53).
|
|
3
|
+
// `friday-google-cloud install` is `friday install --with <this package>`; every other argument
|
|
4
|
+
// passes through unchanged.
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const here = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
11
|
+
const cli = createRequire(import.meta.url).resolve("@digital-agora/friday/dist/cli.js");
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const WITH = new Set(["validate", "build", "bundle", "install", "list", "graph"]);
|
|
14
|
+
if (args.length && WITH.has(args[0])) args.push("--with", join(here));
|
|
15
|
+
const r = spawnSync(process.execPath, [cli, ...args], { stdio: "inherit" });
|
|
16
|
+
process.exit(r.status ?? 1);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
id: cloud-run
|
|
2
|
+
stack: cloud-run
|
|
3
|
+
description: Cloud Run services.
|
|
4
|
+
appliesTo:
|
|
5
|
+
paths: ["services/**", "cloudbuild/**"]
|
|
6
|
+
emit: [rule, skill]
|
|
7
|
+
rules:
|
|
8
|
+
- id: auth-in-app
|
|
9
|
+
rule: A public service (Invoker IAM check disabled, or --allow-unauthenticated) is deliberate and recorded; the app then verifies every token itself.
|
|
10
|
+
source: https://docs.cloud.google.com/run/docs/authenticating/public
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Google Cloud's rules for the config-secrets convention: each replaces Friday's rule with its id,
|
|
2
|
+
# or is added (decision 41).
|
|
3
|
+
id: config-secrets
|
|
4
|
+
rules:
|
|
5
|
+
- id: secrets
|
|
6
|
+
rule: Secrets live in Secret Manager, read at run time by the workload's own service account (least privilege per secret), or by one Cloud Build step through availableSecrets and secretEnv. Never in a flag, an image layer, a log or a committed file, and prefer the Secret Manager API over environment variables and files.
|
|
7
|
+
source: https://docs.cloud.google.com/secret-manager/docs/best-practices
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
id: firestore-data
|
|
2
|
+
stack: firestore
|
|
3
|
+
description: Where protected fields live in Firestore, and what client rules do not protect.
|
|
4
|
+
emit: [rule, skill]
|
|
5
|
+
rules:
|
|
6
|
+
- id: protected-fields-private
|
|
7
|
+
rule: "Rules grant whole documents, never fields. A field some readers must not see (personal data such as a birth year, an email or a barcode; staff-only values) lives only in a separate document under `<parent>/private/<doc>`, never next to public fields. The public document keeps what live views read."
|
|
8
|
+
why: Reads are performed at the document level; it is impossible with rules alone to stop users reading specific fields of a document.
|
|
9
|
+
source: https://firebase.google.com/docs/firestore/security/rules-fields
|
|
10
|
+
- id: server-access-is-iam
|
|
11
|
+
rule: "Server code (the Admin SDK, the server client libraries) bypasses every rule, so private documents are protected from servers only by IAM: database roles (roles/datastore.*) go only to the service accounts whose code reads those documents, and a broad viewer or user grant is a gap to close, not an accepted risk."
|
|
12
|
+
source: https://firebase.google.com/docs/firestore/security/get-started
|
|
13
|
+
- id: no-values-in-paths
|
|
14
|
+
rule: A protected value is never part of a document id, a collection name or any path. Index by a random id or a keyed hash and keep the value in the private document's fields.
|
|
15
|
+
why: Paths appear in logs, audit entries, exports and error messages; Google asks for no personal or security data in resource names.
|
|
16
|
+
source: https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects
|
|
17
|
+
- id: exports
|
|
18
|
+
rule: Managed exports and backups contain the private documents too. Their Cloud Storage bucket and the export and import roles are restricted like the data itself.
|
|
19
|
+
source: https://docs.cloud.google.com/firestore/native/docs/manage-data/export-import
|
|
20
|
+
- id: location-once
|
|
21
|
+
rule: The Firestore database location is chosen once and recorded as a decision; it cannot be changed after the database exists.
|
|
22
|
+
source: https://docs.cloud.google.com/firestore/native/docs/locations
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
id: firestore-rules
|
|
2
|
+
stack: firestore
|
|
3
|
+
description: Firestore and Cloud Storage security rules, and the private documents they keep from clients.
|
|
4
|
+
appliesTo:
|
|
5
|
+
paths: ["**/*.rules", "firebase.json"]
|
|
6
|
+
emit: [rule, skill]
|
|
7
|
+
rules:
|
|
8
|
+
- id: deny-all
|
|
9
|
+
rule: Rules start deny-all (locked mode). Every allow is added with emulator tests for the allowed and the denied reads and writes of each caller kind.
|
|
10
|
+
source: https://firebase.google.com/docs/rules/insecure-rules
|
|
11
|
+
- id: private-match
|
|
12
|
+
rule: "Documents under any `private` subcollection have no client access: `rules_version = '2'` and `match /{path=**}/private/{doc} { allow read, write: if false; }`. Only server code reaches them."
|
|
13
|
+
source: https://firebase.google.com/docs/firestore/security/rules-structure
|
|
14
|
+
- id: any-allow-wins
|
|
15
|
+
rule: An allow in any match statement that covers a document grants access, and `if false` elsewhere never takes it back. No recursive wildcard (`{document=**}`) allows reads over a tree that holds `private/` documents; keep them outside such a tree, or narrow the wildcard.
|
|
16
|
+
why: "With overlapping match statements, access is allowed if any of the conditions is true."
|
|
17
|
+
source: https://firebase.google.com/docs/firestore/security/rules-structure
|
|
18
|
+
- id: refusal-tests
|
|
19
|
+
rule: "Each private path has a rules test (@firebase/rules-unit-testing, assertFails) proving that a client read and a client write are refused, for every caller kind including the document's owner. Without that test the path is not private."
|
|
20
|
+
source: https://firebase.google.com/docs/rules/unit-tests
|
|
21
|
+
- id: app-check
|
|
22
|
+
rule: A client write any visitor can make (no signed-in owner) also requires App Check.
|
|
23
|
+
source: https://firebase.google.com/docs/app-check
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
id: gcp-iam
|
|
2
|
+
stack: gcp
|
|
3
|
+
description: Service accounts and credentials on Google Cloud.
|
|
4
|
+
appliesTo:
|
|
5
|
+
paths: [".github/**", "cloudbuild/**", "infra/**", "**/*.tf"]
|
|
6
|
+
emit: [rule, skill]
|
|
7
|
+
rules:
|
|
8
|
+
- id: own-account
|
|
9
|
+
rule: Each service, function codebase and job runs as its own user-managed service account with only the roles it needs. Never the Compute Engine default service account.
|
|
10
|
+
source: https://docs.cloud.google.com/run/docs/securing/service-identity
|
|
11
|
+
- id: no-keys
|
|
12
|
+
rule: No service account keys. CI and deployment pipelines (GitHub Actions and others) authenticate with Workload Identity Federation and short-lived credentials.
|
|
13
|
+
source: https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Google Cloud's rules for the testing convention: each replaces Friday's rule with its id, or is
|
|
2
|
+
# added (decision 41).
|
|
3
|
+
id: testing
|
|
4
|
+
rules:
|
|
5
|
+
- id: demo-ids
|
|
6
|
+
rule: The Firebase emulators always run with a demo- project id, so tests can never reach a real project's resources.
|
|
7
|
+
source: https://firebase.google.com/docs/emulator-suite/connect_firestore
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-agora/friday-google-cloud",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Cloud's specialization of Friday: Firestore, Cloud Run, Cloud Functions, Secret Manager and IAM conventions on top of Friday's generic pack, each citing Google's documentation.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"friday-google-cloud": "bin/friday-google-cloud.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"specialization.yaml",
|
|
12
|
+
"conventions",
|
|
13
|
+
"personas",
|
|
14
|
+
"bin",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@digital-agora/friday": "^0.10.0"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/Digital-Agora/friday.git",
|
|
27
|
+
"directory": "specializations/google-cloud"
|
|
28
|
+
}
|
|
6
29
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
id: security-steward
|
|
2
|
+
conventions: [firestore-rules, firestore-data, gcp-iam]
|
|
3
|
+
prompt: |
|
|
4
|
+
- Protected fields live only in `.../private/...` documents, with a deny-all rule and a test that a client read is refused.
|
|
5
|
+
- Server code bypasses rules: check which service accounts hold database roles.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Google Cloud's specialization of Friday (decision 53): rules that hold for any project on Google
|
|
2
|
+
# Cloud and Firebase (Firestore, Cloud Run, Cloud Functions, Secret Manager, IAM), each citing
|
|
3
|
+
# Google's documentation. Public, on npmjs.com and GitHub Packages. Installed with
|
|
4
|
+
# npx -y @digital-agora/friday-google-cloud install
|
|
5
|
+
# or friday install --with @digital-agora/friday-google-cloud. A project specialization builds on
|
|
6
|
+
# it with `extends` (Hybrid-Day's does).
|
|
7
|
+
id: google-cloud
|
|
8
|
+
name: Google Cloud
|
|
9
|
+
description: SDLC agents, workflows and conventions for projects on Google Cloud and Firebase (Firestore, Cloud Run, Cloud Functions, Secret Manager, IAM).
|
|
10
|
+
testPyramid:
|
|
11
|
+
levels:
|
|
12
|
+
- id: integration
|
|
13
|
+
description: Adapters and rules against the Firebase emulators, with a demo- project id
|
|
14
|
+
commands: ['firebase emulators:exec --only firestore --project demo-<name> "<integration test command>"']
|
|
15
|
+
source: https://firebase.google.com/docs/emulator-suite/connect_firestore
|
|
16
|
+
forbiddenInLoop: ["emulators:exec", "emulators:start"]
|