Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PasteBin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Arrêt du service - 11/07 de 07h30 à 07h45 - Mise à jour de sécurité
Show more breadcrumbs
PIERRON Laurent
PasteBin
Commits
07bc3285
Unverified
Commit
07bc3285
authored
2 years ago
by
El RIDO
Browse files
Options
Downloads
Patches
Plain Diff
moved glob iterator pattern to const, documentation
parent
02a7be46
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Data/Filesystem.php
+22
-11
22 additions, 11 deletions
lib/Data/Filesystem.php
with
22 additions
and
11 deletions
lib/Data/Filesystem.php
+
22
−
11
View file @
07bc3285
...
...
@@ -22,6 +22,22 @@ use PrivateBin\Json;
*/
class
Filesystem
extends
AbstractData
{
/**
* glob() pattern of the two folder levels and the paste files under the
* configured path. Needs to return both files with and without .php suffix,
* so they can be hardened by _prependRename(), which is hooked into exists().
*
* > Note that wildcard patterns are not regular expressions, although they
* > are a bit similar.
*
* @link https://man7.org/linux/man-pages/man7/glob.7.html
* @const string
*/
const
PASTE_FILE_PATTERN
=
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9]'
.
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9]'
.
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]'
.
'[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*'
;
/**
* first line in paste or comment files, to protect their contents from browsing exposed data directories
*
...
...
@@ -341,10 +357,9 @@ class Filesystem extends AbstractData
protected
function
_getExpiredPastes
(
$batchsize
)
{
$pastes
=
array
();
$files
=
$this
->
_getPasteIterator
();
$count
=
0
;
$time
=
time
();
foreach
(
$
files
as
$file
)
{
foreach
(
$
this
->
_getPasteIterator
()
as
$file
)
{
if
(
$file
->
isDir
())
{
continue
;
}
...
...
@@ -372,8 +387,7 @@ class Filesystem extends AbstractData
public
function
getAllPastes
()
{
$pastes
=
array
();
$files
=
$this
->
_getPasteIterator
();
foreach
(
$files
as
$file
)
{
foreach
(
$this
->
_getPasteIterator
()
as
$file
)
{
if
(
$file
->
isFile
())
{
$pastes
[]
=
$file
->
getBasename
(
'.php'
);
}
...
...
@@ -419,19 +433,16 @@ class Filesystem extends AbstractData
/**
* Get an iterator matching paste files.
*
* Note that creating the iterator issues the glob() call, so we can't pre-
* generate this object before files that should get matched exist.
*
* @access private
* @return \GlobIterator
*/
private
function
_getPasteIterator
()
{
return
new
\GlobIterator
(
$this
->
_path
.
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9]'
.
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9]'
.
DIRECTORY_SEPARATOR
.
'[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]'
.
'[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*'
);
// need to return both files with and without .php suffix, so they can
// be hardened by _prependRename(), which is hooked into exists()
return
new
\GlobIterator
(
$this
->
_path
.
self
::
PASTE_FILE_PATTERN
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment