Giter VIP home page Giter VIP logo

alexruperez / safebrowsing Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 6.0 96 KB

Protect your users against malware and phishing threats using Google Safe Browsing

Home Page: https://developers.google.com/safe-browsing

License: MIT License

Swift 94.03% Ruby 3.79% Objective-C 2.18%
google google-safebrowsing safebrowsing swift swift-library api-wrapper safe-browsing malware-detection phising protect-your-privacy

safebrowsing's Introduction

SafeBrowsing

Twitter Version License Platform Swift Carthage compatible Swift Package Manager Compatible Build Status codecov

Protect your users against malware and phishing threats using Google Safe Browsing

SafeBrowsing

๐ŸŒŸ Features

  • Check multiple URLs asynchronously
  • Check single URL asynchronously
  • Check single URL synchronously
  • Open URL in Safari only if it's safe
  • UIApplication extension
  • UIViewController extension
  • SFSafariViewController compatible

๐Ÿ“ฒ Installation

SafeBrowsing is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SafeBrowsing'

Or you can install it with Carthage:

github "alexruperez/SafeBrowsing"

Or install it with Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/alexruperez/SafeBrowsing.git", from: "0.1.0")
]

๐Ÿ›  Configuration

Required configuration

Just enable Google Safe Browsing API and get your API key.

SafeBrowsing.apiKey = "YOUR_API_KEY_HERE"

Advanced optional configuration

You can easily customize threat types, platform types or threat entry types.

SafeBrowsing.clientId = "YOUR_CLIENT_ID" // By default your bundle identifier.
SafeBrowsing.clientVersion = "YOUR_CLIENT_VERSION" // By default your bundle short version.
SafeBrowsing.threatTypes = [.malware, .socialEngineering, .unwantedSoftware, .potenciallyHarmfulApplication]
SafeBrowsing.platformTypes = [.any]
SafeBrowsing.threatEntryTypes = [.url, .executable]

๐Ÿ’ Usage

Check multiple URLs asynchronously:

SafeBrowsing.isSafe([anURL, anotherURL]) { isSafe, error in
    // Your code here
}

Check single URL asynchronously:

SafeBrowsing.isSafe(anURL) { isSafe, error in
    // Your code here
}

Check single URL synchronously:

Caution: Don't call it in main thread
if SafeBrowsing.isSafe(anURL) {
    // Your code here
}

Open URL in Safari only if it's safe:

SafeBrowsing.safeOpen(anURL) { opened, error in
    // Your code here
}

Open URL in SFSafariViewController only if it's safe:

SafeBrowsing.safeOpenInSafariViewController(anURL, over: aViewController, animated: true) { opened, error in
    // Your code here
}

UIApplication extension

Yes, you can use SafeBrowsing with UIApplication, just like open(_:options:completionHandler:) method works.

You also have all isSafe(_:) methods available with this extension.

UIApplication.shared.safeOpen(anURL) { opened, error in
    // Your code here
}

Open URL in SFSafariViewController only if it's safe:

UIApplication.shared.safeOpenInSafariViewController(anURL, over: aViewController, animated: true) { opened, error in
    // Your code here
}

UIViewController extension

aViewController.safeOpenInSafariViewController(anURL, animated: true) { opened, error in
    // Your code here
}

Testing Google Safe Browsing

let testingURL = URL(string: "http://malware.testing.google.test/testing/malware/")!
SafeBrowsing.isSafe(testingURL) { isSafe, error in
    print(error.debugDescription)
}

โค๏ธ Etc.

  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

๐Ÿ‘จโ€๐Ÿ’ป Authors

alexruperez, [email protected]

๐Ÿ‘ฎโ€โ™‚๏ธ License

SafeBrowsing is available under the MIT license. See the LICENSE file for more info.

safebrowsing's People

Contributors

alexruperez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.