Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent the Logger from writing sensitive values #143

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Integration

on:
pull_request:
paths:
- '.github/workflows/integration.yml'
- 'appinfo/**'
- 'lib/**'
- 'tests/**'

push:
branches:
- master
- stable*

env:
APP_NAME: sharepoint

jobs:
sqlite:
runs-on: ubuntu-latest

strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
databases: ['sqlite']
server-versions: ['master']

name: integration-php${{ matrix.php-versions }}-${{ matrix.databases }}

steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}

- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
ini-values: zend.exception_ignore_args=Off
coverage: none

- name: Install app dependencies
working-directory: apps/${{ env.APP_NAME }}
run: composer i

- name: Install test dependencies
working-directory: apps/${{ env.APP_NAME }}/tests/Integration
run: composer i

- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
php -f index.php
./occ app:enable files_external
./occ app:enable --force ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: Integration
working-directory: apps/${{ env.APP_NAME }}/tests/Integration
run: bash run.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
composer.phar
/vendor/
vendor/
4 changes: 4 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use Office365\Runtime\Auth\AuthenticationContext;
use Office365\Runtime\Auth\SamlTokenProvider;
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing both paths being in the same namespace, does it make sense to allow giving class names only or even namespaces only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both might be too broad in other cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's why I meant "Allow", but yeah then let's keep it like this.
I just fear the moment they change an internal method name or something and it logs again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's why I meant "Allow", but yeah then let's keep it like this. I just fear the moment they change an internal method name or something and it logs again

Absolutely. But that can happen to namespaces as well as class names (also happened in this lib in the past).

The only sustainable solution will arrive with PHP 8.2's sensitive parameter support.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickvergessen added an integrattion test that should act as safeguard nevertheless


class Application extends App implements IBootstrap {
public function __construct() {
parent::__construct('sharepoint');
}

public function register(IRegistrationContext $context): void {
$context->registerSensitiveMethods(SamlTokenProvider::class, ['acquireSecurityToken']);
$context->registerSensitiveMethods(AuthenticationContext::class, ['acquireToken', 'acquireTokenForUser']);
$context->registerEventListener('OCA\\Files_External::loadAdditionalBackends', ExternalStoragesRegistrationListener::class);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Integration/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"config": {
"platform": {
"php": "7.4"
}
},
"require-dev": {
"behat/behat": "^3.11",
"jarnaiz/behat-junit-formatter": "^1.3",
"guzzlehttp/guzzle": "^7.4"
}
}
Loading