path, strlen( $ctx->pluginsDir ) + 1 ); $pos = strpos( $rel, '/' ); if ( false === $pos ) { return self::singleFile( $f, $rel, $ctx ); } $dir = substr( $rel, 0, $pos ); $inner = substr( $rel, $pos + 1 ); $plug = $ctx->pluginFor( $dir, true ); if ( null === $plug || ! isset( $ctx->pluginChecksums[ $dir ] ) ) { return array(); } $sums = $ctx->pluginChecksums[ $dir ]; $args = array( $f->path, $dir, $sums->version ); if ( $sums->has( $inner ) ) { list( $ok, $algo ) = $sums->compare( $inner, $f->md5, $f->sha256 ); if ( false === $ok ) { $args[] = $algo; return array( Finding::make( 'plugin_modified', $f->path, $args ) ); } return array(); } if ( Text::isPhpFile( $inner ) ) { if ( self::isInertIndex( $f ) ) { return array( Finding::make( 'plugin_silence_index', $f->path, array( $f->path ) ) ); } return array( Finding::make( 'plugin_unknown_php', $f->path, $args ) ); } return array( Finding::make( 'plugin_extra_file', $f->path, $args ) ); } /** * index.php of at most 200 bytes that runs no code: the silence index of control 3 * (PHP opening tag and comments only), or a text without any "path ) ) || $f->size > Assumptions::SILENCE_INDEX_MAX_BYTES ) { return false; } if ( UploadsRules::isSilenceIndex( $f ) ) { return true; } $s = null !== $f->content ? $f->content : $f->head; return null !== $s && strlen( $s ) === $f->size && false === strpos( $s, 'coreChecksums; if ( null === $core || ! isset( $core->sums[ Assumptions::CORE_HELLO_KEY ] ) || null === $f->md5 ) { return array(); } if ( $f->md5 !== $core->sums[ Assumptions::CORE_HELLO_KEY ] ) { return array( Finding::make( 'plugin_hello_modified', $f->path, array( $f->path, $core->version, $core->locale ) ) ); } return array(); } if ( null === $ctx->pluginFor( $rel, false ) ) { return array(); } $slug = Context::slugOf( $rel ); if ( ! isset( $ctx->pluginChecksums[ $slug ] ) || ! $ctx->pluginChecksums[ $slug ]->has( $rel ) ) { return array(); } $sums = $ctx->pluginChecksums[ $slug ]; list( $ok, $algo ) = $sums->compare( $rel, $f->md5, $f->sha256 ); if ( false === $ok ) { return array( Finding::make( 'plugin_modified', $f->path, array( $f->path, $slug, $sums->version, $algo ) ) ); } return array(); } }