Skip to content

Commit

Permalink
fix: Use correct URL for shard credentials (#2997)
Browse files Browse the repository at this point in the history
Both the location and the format of the file have changed.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Nov 23, 2024
1 parent ecb848f commit 9f3b2d3
Show file tree
Hide file tree
Showing 2 changed files with 6,509 additions and 9,446 deletions.
22 changes: 18 additions & 4 deletions pkg/pwgen/pwrules/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

const (
aliasURL = "https://raw.githubusercontent.com/apple/password-manager-resources/main/quirks/websites-with-shared-credential-backends.json"
aliasURL = "https://raw.githubusercontent.com/apple/password-manager-resources/main/quirks/shared-credentials.json"
changeURL = "https://raw.githubusercontent.com/apple/password-manager-resources/main/quirks/change-password-URLs.json"
rulesURL = "https://raw.githubusercontent.com/apple/password-manager-resources/main/quirks/password-rules.json"
)
Expand Down Expand Up @@ -68,19 +68,33 @@ func main() {
})
}

type aliasRule struct {
Shared []string `json:"shared"`
From []string `json:"from"`
To []string `json:"to"`
FromDomainsAreObsolete bool `json:"fromDomainsAreObsolete"`
}

func fetchAliases() (map[string][]string, error) {
resp, err := http.Get(aliasURL)
if err != nil {
return nil, err
}
var ja [][]string
var ja []aliasRule
if err := json.NewDecoder(resp.Body).Decode(&ja); err != nil {
return nil, err
}
aliases := make(map[string][]string, len(ja))
for _, as := range ja {
for _, a := range as {
aliases[a] = as
for _, a := range as.Shared {
aliases[a] = as.Shared
}
if len(as.Shared) > 0 {
continue
}

for _, f := range as.From {
aliases[f] = as.To
}
}
return aliases, nil
Expand Down
Loading

0 comments on commit 9f3b2d3

Please sign in to comment.