-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from wneessen/breaches
Added BreachByName() to breaches API
- Loading branch information
Showing
5 changed files
with
217 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
hibp "github.com/wneessen/go-hibp" | ||
) | ||
|
||
func main() { | ||
hc := hibp.New() | ||
if hc == nil { | ||
panic("failed to create HIBP client") | ||
} | ||
|
||
bl, _, err := hc.BreachApi.Breaches() | ||
if err != nil { | ||
panic(err) | ||
} | ||
if bl != nil && len(bl) != 0 { | ||
fmt.Printf("Found %d breaches total.\n", len(bl)) | ||
} | ||
|
||
bl, _, err = hc.BreachApi.Breaches(hibp.WithoutUnverified()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if bl != nil && len(bl) != 0 { | ||
fmt.Printf("Found %d verified breaches total.\n", len(bl)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
hibp "github.com/wneessen/go-hibp" | ||
) | ||
|
||
func main() { | ||
hc := hibp.New() | ||
if hc == nil { | ||
panic("failed to create HIBP client") | ||
} | ||
|
||
bl, _, err := hc.BreachApi.Breaches() | ||
if err != nil { | ||
panic(err) | ||
} | ||
if bl != nil && len(bl) != 0 { | ||
for _, b := range bl { | ||
fmt.Printf("Found breach:\n\tName: %s\n\tDomain: %s\n\tBreach date: %s\n\n", | ||
b.Name, b.Domain, b.BreachDate.Time().Format("Mon, 2. January 2006")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
hibp "github.com/wneessen/go-hibp" | ||
) | ||
|
||
func main() { | ||
hc := hibp.New() | ||
if hc == nil { | ||
panic("failed to create HIBP client") | ||
} | ||
|
||
bd, _, err := hc.BreachApi.BreachByName("Adobe") | ||
if err != nil { | ||
panic(err) | ||
} | ||
if bd != nil { | ||
fmt.Println("Details of the 'Adobe' breach:") | ||
fmt.Printf("\tDomain: %s\n", bd.Domain) | ||
fmt.Printf("\tBreach date: %s\n", bd.BreachDate.Time().Format("2006-01-02")) | ||
fmt.Printf("\tAdded to HIBP: %s\n", bd.AddedDate.String()) | ||
|
||
} | ||
} |