├── .github ├── FUNDING.yml └── workflows │ ├── fix-php-code-style-issues.yml │ ├── run-tests.yml │ └── update-changelog.yml ├── .phpunit.cache └── test-results ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── UPGRADING.md ├── composer.json └── src ├── Exceptions └── InvalidUrl.php ├── MixedContent.php ├── MixedContentExtractor.php ├── MixedContentObserver.php └── MixedContentScanner.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: spatie 2 | -------------------------------------------------------------------------------- /.github/workflows/fix-php-code-style-issues.yml: -------------------------------------------------------------------------------- 1 | name: Fix PHP code style issues 2 | 3 | on: 4 | push: 5 | paths: 6 | - '**.php' 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | php-code-styling: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v3 18 | with: 19 | ref: ${{ github.head_ref }} 20 | 21 | - name: Fix PHP code style issues 22 | uses: aglipanci/laravel-pint-action@2.3.0 23 | 24 | - name: Commit changes 25 | uses: stefanzweifel/git-auto-commit-action@v4 26 | with: 27 | commit_message: Fix styling 28 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | os: [ubuntu-latest] 12 | php: [8.1, 8.2] 13 | dependency-version: [prefer-lowest, prefer-stable] 14 | 15 | name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} 16 | 17 | steps: 18 | - name: Checkout code 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup PHP 22 | uses: shivammathur/setup-php@v2 23 | with: 24 | php-version: ${{ matrix.php }} 25 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 26 | coverage: none 27 | 28 | - name: Install dependencies 29 | run: composer update --no-interaction --prefer-source 30 | 31 | - name: Execute tests 32 | run: vendor/bin/phpunit 33 | -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Update Changelog" 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | update: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | with: 15 | ref: main 16 | 17 | - name: Update Changelog 18 | uses: stefanzweifel/changelog-updater-action@v1 19 | with: 20 | latest-version: ${{ github.event.release.name }} 21 | release-notes: ${{ github.event.release.body }} 22 | 23 | - name: Commit updated CHANGELOG 24 | uses: stefanzweifel/git-auto-commit-action@v4 25 | with: 26 | branch: main 27 | commit_message: Update CHANGELOG 28 | file_pattern: CHANGELOG.md 29 | -------------------------------------------------------------------------------- /.phpunit.cache/test-results: -------------------------------------------------------------------------------- 1 | {"version":1,"defects":[],"times":{"Spatie\\MixedContentScanner\\Test\\InvalidUrlTest::it_will_throw_an_exception_when_scanning_an_empty_url":0.003,"Spatie\\MixedContentScanner\\Test\\InvalidUrlTest::it_will_throw_an_exception_when_scanning_an_url_with_an_invalid_protocol":0,"Spatie\\MixedContentScanner\\Test\\MixedContentScannerTest::it_can_find_mixed_content":0.052,"Spatie\\MixedContentScanner\\Test\\MixedContentScannerTest::it_will_only_mark_stylesheet_rel_as_mixed_content":0.006,"Spatie\\MixedContentScanner\\Test\\MixedContentScannerTest::it_will_throw_an_exception_when_given_an_url_with_an_invalid_protocol":0,"Spatie\\MixedContentScanner\\Test\\MixedContentScannerTest::it_can_limit_the_amout_of_crawled_urls":0.009,"Spatie\\MixedContentScanner\\Test\\MixedContentScannerTest::it_can_scan_pages_not_ending_in_slash":0.005,"Spatie\\MixedContentScanner\\Test\\MixedContentTest::it_can_convert_itself_to_an_array":0}} -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `mixed-content-scanner` will be documented in this file 4 | 5 | ## 5.0.0 - 2023-06-04 6 | 7 | - use crawler v8 8 | 9 | ## 4.0.4 - 2023-03-06 10 | 11 | ### What's Changed 12 | 13 | - Fix tests on PHP 8.1 by @SamuelNitsche in https://github.com/spatie/mixed-content-scanner/pull/47 14 | - Fix of issue #48 by @codeinnovers in https://github.com/spatie/mixed-content-scanner/pull/49 15 | 16 | ### New Contributors 17 | 18 | - @codeinnovers made their first contribution in https://github.com/spatie/mixed-content-scanner/pull/49 19 | 20 | **Full Changelog**: https://github.com/spatie/mixed-content-scanner/compare/4.0.3...4.0.4 21 | 22 | ## 4.0.3 23 | 24 | - allow crawler v7 25 | 26 | ## 4.0.2 27 | 28 | - allow crawler v6 29 | 30 | ## 4.0.1 31 | 32 | - allow PHP 8 33 | 34 | ## 3.3.0 35 | 36 | - revert changes in 3.2.0 37 | 38 | ## 3.2.0 39 | 40 | - add scan css 41 | 42 | ## 3.1.0 - 2018-03-22 43 | 44 | - Respect robots. 45 | 46 | ## 3.0.2 - 2018-03-02 47 | 48 | - Update `spatie/crawler` to support correct `Collection` packages. 49 | - Remove unneeded `cighten/collect` dependency. 50 | 51 | ## 3.0.1 - 2018-03-01 52 | 53 | - improve constraints 54 | 55 | ## 3.0.0 - 2018-03-01 56 | 57 | - upgrade `spatie/crawler` to 4.0 58 | 59 | ## 2.1.1 - 2018-01-23 60 | 61 | - add `configureCrawler` 62 | 63 | ## 2.1.0 - 2018-01-23 64 | 65 | **broken release, do not use** 66 | 67 | - add `configureCrawler` 68 | 69 | ## 2.0.1 - 2017-01-10 70 | 71 | - ignore invalid links 72 | 73 | ## 2.0.0 - 2017-12-22 74 | 75 | - upgrade `spatie/crawler` to 3.0 76 | 77 | ## 1.2.1 - 2017-10-09 78 | 79 | - only consider links with rel stylesheet as canidates for mixed content 80 | 81 | ## 1.2.0 - 2017-09-27 82 | 83 | - add `setMaximumCrawlCount` 84 | 85 | ## 1.1.1 - 2017-08-23 86 | 87 | - do not mark shortlinks as mixed content 88 | 89 | ## 1.1.0 - 2017-08-11 90 | 91 | - add `toArray` to `MixedContent` 92 | 93 | ## 1.0.1 - 2017-08-03 94 | 95 | - lower reqs 96 | 97 | ## 1.0.0 - 2017-08-03 98 | 99 | - initial release 100 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Spatie bvba 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scan your site for mixed content 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/mixed-content-scanner.svg?style=flat-square)](https://packagist.org/packages/spatie/mixed-content-scanner) 4 | ![Tests](https://github.com/spatie/mixed-content-scanner/workflows/Tests/badge.svg) 5 | [![Total Downloads](https://img.shields.io/packagist/dt/spatie/mixed-content-scanner.svg?style=flat-square)](https://packagist.org/packages/spatie/mixed-content-scanner) 6 | 7 | This package contains a class that can scan your site for [mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content). 8 | 9 | Here's an example of how you can use it: 10 | 11 | ```php 12 | use Spatie\MixedContentScanner\MixedContentScanner; 13 | 14 | $logger = new MixedContentLogger(); 15 | 16 | $scanner = new MixedContentScanner($logger); 17 | 18 | $scanner->scan('https://example.com'); 19 | ``` 20 | 21 | `MixedContentLogger` is a class containing methods that get called when mixed content is (not) found. 22 | 23 | If you don't need a custom implementation but simply want to look for mixed content using a command line tool, take a look at [our mixed-content-scanner-cli package](https://github.com/spatie/mixed-content-scanner-cli). 24 | 25 | ## Support us 26 | 27 | Learn how to create a package like this one, by watching our premium video course: 28 | 29 | [![Laravel Package training](https://spatie.be/github/package-training.jpg)](https://laravelpackage.training) 30 | 31 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 32 | 33 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 34 | 35 | ## Installation 36 | 37 | You can install the package via composer: 38 | 39 | ```bash 40 | composer require spatie/mixed-content-scanner 41 | ``` 42 | 43 | ## How it works under the hood 44 | 45 | When scanning a site, the scanner will crawl everypage. On the retrieve html, these elements and attributes will be checked: 46 | 47 | - `audio`: `src` 48 | - `embed`: `src` 49 | - `form`: `action` 50 | - `link`: `href` 51 | - `iframe`: `src` 52 | - `img`: `src`, `srcset` 53 | - `object`: `data` 54 | - `param`: `value` 55 | - `script`: `src` 56 | - `source`: `src`, `srcset` 57 | - `video`: `src` 58 | 59 | If any of those attributes start with `http://` the element will be regarded as mixed content. 60 | 61 | The package does not scan linked `.css` or `.js` files, nor does it take inline `