Skip to content

Commit

Permalink
Merge branch 'apple:main' into citiretailservices-rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Sameesunkaria authored Jun 27, 2022
2 parents 020fc75 + 9dff1e5 commit 5c989bc
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 3 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- name: Lint Valid Json
run: |
find quirks/ -name '*.json' -print0 | while IFS= read -r -d '' filename; do
find quirks/ -name '*.json' -print0 -maxdepth 1 | while IFS= read -r -d '' filename; do
echo "Validating $(basename "$filename")"
python -mjson.tool "$filename" > /dev/null
done
Expand Down Expand Up @@ -39,4 +39,14 @@ jobs:
- name: Lint Sort Order
run: ruby .github/workflows/lint-scripts/websites-shared-credentials-sort-order.rb
- name: Lint Duplicates
run: ruby .github/workflows/lint-scripts/websites-shared-credentials-duplicates.rb
run: ruby .github/workflows/lint-scripts/websites-shared-credentials-duplicates.rb

validate-schemas:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- name: Install ajv-cli
run: npm install -g ajv-cli
- name: Validate JSONs against their schemas
run: ./tools/validate-json-schemas.sh
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Before contributing, please review the [Code of Conduct](CODE_OF_CONDUCT.md).

Contributing is easy! You can contribute either by raising compatibility issues with a website, researching and documenting what the right data for a quirk might be, and/or submitting a pull request to add a quirk. You can raise an issue at the repository's [issues page](https://github.com/apple/password-manager-resources/issues). If you've done some investigation into a service's behavior, you can document it on an existing issue for that problem. If you'd like to submit a pull request, there are some additional special considerations for each type of quirk, detailed below.

When adding a data item to a top-level JSON object, please keep keys alphabetized. This assists with scanning the lists and with merging them.
When adding a data item to a top-level JSON object, please keep keys alphabetized. This assists with scanning the lists and with merging them. You may run the [`tools/validate-json-schemas.sh`](tools/validate-json-schemas.sh) script to validate the JSON files before making a commit.

One more point to consider is to keep your pull requests small and limited in scope to a specific change. (For example, it's best to submit a "Password Rule" for a single website or group of related websites in one pull request and not conflate unrelated changes that can prevent other from being merged.)

Expand Down
3 changes: 3 additions & 0 deletions quirks/password-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@
"planetary.org": {
"password-rules": "minlength: 5; maxlength: 20; required: lower; required: upper; required: digit; allowed: ascii-printable;"
},
"plazapremiumlounge.com": {
"password-rules": "minlength: 8; maxlength: 15; required: lower; required: upper; required: digit; allowed: [!#$%&*,@^];"
},
"portal.edd.ca.gov": {
"password-rules": "minlength: 8; required: lower; required: upper; required: digit; required: [!#$%&()*@^];"
},
Expand Down
7 changes: 7 additions & 0 deletions quirks/schemas/change-password-URLs-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": {
"type": "string"
}
}
16 changes: 16 additions & 0 deletions quirks/schemas/password-rules-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"password-rules": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"password-rules"
]
}
}
49 changes: 49 additions & 0 deletions quirks/schemas/shared-credentials-historical-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"domain-list": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
},
"minItems": 1
}
},
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"shared": {
"$ref": "#/definitions/domain-list"
}
},
"additionalProperties": false,
"required": [
"shared"
]
},
{
"type": "object",
"properties": {
"from": {
"$ref": "#/definitions/domain-list"
},
"to": {
"$ref": "#/definitions/domain-list"
},
"fromDomainsAreObsoleted": {
"type": "boolean"
}
},
"additionalProperties": false,
"required": [
"from",
"to"
]
}
]
}
}
49 changes: 49 additions & 0 deletions quirks/schemas/shared-credentials-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"domain-list": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
},
"minItems": 1
}
},
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"shared": {
"$ref": "#/definitions/domain-list"
}
},
"additionalProperties": false,
"required": [
"shared"
]
},
{
"type": "object",
"properties": {
"from": {
"$ref": "#/definitions/domain-list"
},
"to": {
"$ref": "#/definitions/domain-list"
},
"fromDomainsAreObsoleted": {
"type": "boolean"
}
},
"additionalProperties": false,
"required": [
"from",
"to"
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
},
"minItems": 1
}
}
17 changes: 17 additions & 0 deletions tools/validate-json-schemas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

if ! command -v ajv &> /dev/null
then
echo "The 'ajv' command is required for validating JSON schemas.
Please follow the readme at https://github.com/ajv-validator/ajv-cli to install the 'ajv-cli' package."
exit 1
fi

# Finds all JSON files in the quirks directory and validates them against the corresponding schema.
find quirks -name '*.json' -print0 -maxdepth 1 | while IFS= read -r -d '' filename; do
schema="quirks/schemas/$(basename "$filename" .json)-schema.json"
echo "Validating $filename against $schema"
ajv -s "$schema" -d "$filename" --spec=draft2020
done

0 comments on commit 5c989bc

Please sign in to comment.