Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Jun 29, 2016
1 parent 9f3a972 commit 3b6e9d5
Show file tree
Hide file tree
Showing 16 changed files with 586 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: psr2
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

All notable changes to `safebrowsing` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## NEXT - YYYY-MM-DD

### Added
- Nothing

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing
22 changes: 22 additions & 0 deletions CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

We accept contributions via Pull Requests on [Github](https://github.com/snipe/Safebrowsing).


## Pull Requests

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests. From the package directory:

`../../../vendor/bin/phpunit`

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

- **Create feature branches** - Don't ask us to pull from your master branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.


## Running Tests

``` bash
$ composer test
```


**Happy coding**!
File renamed without changes.
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# safebrowing
# Safebrowsing

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads]

This is a Laravel 5 package to easily enable you to interface with the Google Safebrowsing API and other RBL services that check for malicious links.

## Install

Via Composer

``` bash
$ composer require snipe/safebrowsing
```

## Usage

``` php
$safebrowsing = new Snipe\safebrowsing();
echo $safebrowsing->echoPhrase('Hello, League!');
```

## Change log

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Testing

``` bash
$ composer test
```

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [A. Gianotto][link-author]
- [All Contributors][link-contributors]

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

[ico-version]: https://img.shields.io/packagist/v/snipe/safebrowsing.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/snipe/safebrowsing/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/snipe/safebrowsing.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/snipe/safebrowsing.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/snipe/safebrowsing.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/snipe/safebrowsing
[link-travis]: https://travis-ci.org/snipe/safebrowsing
[link-scrutinizer]: https://scrutinizer-ci.com/g/snipe/safebrowsing/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/snipe/safebrowsing
[link-downloads]: https://packagist.org/packages/snipe/safebrowsing
[link-author]: https://github.com/snipe
[link-contributors]: ../../contributors
25 changes: 25 additions & 0 deletions Tests/SafebrowsingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
class SafebrowsingTest extends TestCase
{
public function testAddCheckUrls()
{

$start_urls = [
'http://yahoo.com',
'http://google.com'
];

Safebrowsing::addCheckUrls($start_urls);

$add_urls = [
'http://snipe.net',
'http://ianfette.org',
];

Safebrowsing::addCheckUrls($add_urls);
$this->assertEquals(4, count(Safebrowsing::getUrls()));
$this->assertEquals($add_urls[1], Safebrowsing::getUrls()[3]);
$this->assertEquals($start_urls[0], Safebrowsing::getUrls()[0]);

}
}
46 changes: 46 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "Snipe/Safebrowsing",
"type": "library",
"description": ":package_description",
"keywords": [
"Snipe",
"Safebrowsing"
],
"homepage": "https://github.com/Snipe/Safebrowsing",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": ":author_email",
"homepage": ":author_website",
"role": "Developer"
}
],
"require": {
"illuminate/support": "~5.1",
"php" : "~5.5|~7.0"
},
"require-dev": {
"phpunit/phpunit" : "~4.0||~5.0",
"scrutinizer/ocular": "~1.1",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
"psr-4": {
"Snipe\\Safebrowsing\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Snipe\\Safebrowsing\\": "tests"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
56 changes: 56 additions & 0 deletions src/Config/safebrowsing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

use Aws\Laravel\AwsServiceProvider;

return [

/*
|--------------------------------------------------------------------------
| Google Safebrowsing Configuration
|--------------------------------------------------------------------------
| Many of these entries can be left as default unless you want something different, however
| the Google Safebrowsing key is required.
|
| IMPORTANT: Google Safebrowsing free tier is throttled. You can view your current API
| limits here: https://console.cloud.google.com/apis/api/safebrowsing.googleapis.com/quotas?project=laravel-safebrowsing-test
|
| For more information on options:
|
| Platform Type: https://developers.google.com/safe-browsing/v4/reference/rest/v4/PlatformType
| Threat Types: https://developers.google.com/safe-browsing/v4/reference/rest/v4/ThreatType
*/

'google' => [
'api_key' => env('GOOGLE_API_KEY'),
'timeout' => 10,
'threat_types' => [
'THREAT_TYPE_UNSPECIFIED',
'MALWARE',
'SOCIAL_ENGINEERING',
'UNWANTED_SOFTWARE',
'POTENTIALLY_HARMFUL_APPLICATION',
],

'threat_platforms' => [
'PLATFORM_TYPE_UNSPECIFIED',
'WINDOWS',
'LINUX',
'ANDROID',
'OSX',
'IOS',
'ANY_PLATFORM',
],

'clientId' => 'snipe-safebrowsing',
'clientVersion' => '1.0',
],


// These are not currently working
'rbls' => [
'zen.spamhaus.org',
'multi.surbl.org',
'black.uribl.com',
],

];
12 changes: 12 additions & 0 deletions src/Facade/Safebrowsing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php namespace Snipe\Safebrowsing\Facade;

use Illuminate\Support\Facades\Facade;

class Safebrowsing extends Facade {

protected static function getFacadeAccessor()
{
return 'safebrowsing';
}

}
5 changes: 5 additions & 0 deletions src/Lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'greeting' => 'Hello to all of you!'
];
5 changes: 5 additions & 0 deletions src/Lang/jp/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'greeting' => "Kon'nichiwa, anata no subete ni!"
];
Loading

0 comments on commit 3b6e9d5

Please sign in to comment.