mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-04 08:21:40 +00:00
Compare commits
15 commits
96da2b9f1f
...
cee7e2a077
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cee7e2a077 | ||
|
|
2a6e5435e1 | ||
|
|
05b1965957 | ||
|
|
57ef3e06a7 | ||
|
|
7d8a7ab471 | ||
|
|
ad35ae6e9e | ||
|
|
f12f808b34 | ||
|
|
0080aa9f25 | ||
|
|
dc522d4795 | ||
|
|
f07eabd85a | ||
|
|
70454e3a6d | ||
|
|
8b3bebca7b | ||
|
|
4d296d8f3a | ||
|
|
f9a8818e69 | ||
|
|
52df554b29 |
17 changed files with 2036 additions and 2974 deletions
4
.env
4
.env
|
|
@ -121,6 +121,10 @@ SAML_SP_PRIVATE_KEY="MIIE..."
|
||||||
# In demo mode things it is not possible for a user to change his password and his settings.
|
# In demo mode things it is not possible for a user to change his password and his settings.
|
||||||
DEMO_MODE=0
|
DEMO_MODE=0
|
||||||
|
|
||||||
|
# When this is set to 1, users can make Part-DB directly download a file specified as a URL from the local network and create it as a local file.
|
||||||
|
# This allows users access to all resources available in the local network, which could be a security risk, so use this only if you trust your users and have a secure local network.
|
||||||
|
ALLOW_ATTACHMENT_DOWNLOADS_FROM_LOCALNETWORK=0
|
||||||
|
|
||||||
# Change this to true, if no url rewriting (like mod_rewrite for Apache) is available
|
# Change this to true, if no url rewriting (like mod_rewrite for Apache) is available
|
||||||
# In that case all URL contains the index.php front controller in URL
|
# In that case all URL contains the index.php front controller in URL
|
||||||
NO_URL_REWRITE_AVAILABLE=0
|
NO_URL_REWRITE_AVAILABLE=0
|
||||||
|
|
|
||||||
2
.github/workflows/assets_artifact_build.yml
vendored
2
.github/workflows/assets_artifact_build.yml
vendored
|
|
@ -67,7 +67,7 @@ jobs:
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '22'
|
||||||
|
|
||||||
- name: Install yarn dependencies
|
- name: Install yarn dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
|
|
||||||
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
|
@ -106,7 +106,7 @@ jobs:
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '22'
|
||||||
|
|
||||||
- name: Install yarn dependencies
|
- name: Install yarn dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
|
@ -129,7 +129,7 @@ jobs:
|
||||||
run: ./bin/phpunit --coverage-clover=coverage.xml
|
run: ./bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: Upload coverage
|
- name: Upload coverage
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v6
|
||||||
with:
|
with:
|
||||||
env_vars: PHP_VERSION,DB_TYPE
|
env_vars: PHP_VERSION,DB_TYPE
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ RUN yarn build
|
||||||
RUN yarn cache clean && rm -rf node_modules/
|
RUN yarn cache clean && rm -rf node_modules/
|
||||||
|
|
||||||
# FrankenPHP base stage
|
# FrankenPHP base stage
|
||||||
FROM dunglas/frankenphp:1-php8.4 AS frankenphp_upstream
|
FROM dunglas/frankenphp:1-php8.4-bookworm AS frankenphp_upstream
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
RUN --mount=type=cache,id=apt-cache-$TARGETARCH,target=/var/cache/apt \
|
RUN --mount=type=cache,id=apt-cache-$TARGETARCH,target=/var/cache/apt \
|
||||||
--mount=type=cache,id=apt-lists-$TARGETARCH,target=/var/lib/apt/lists \
|
--mount=type=cache,id=apt-lists-$TARGETARCH,target=/var/lib/apt/lists \
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,11 @@ Part-DB is also used by small companies and universities for managing their inve
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* A **web server** (like Apache2 or nginx) that is capable of
|
* A **web server** (like Apache2 or nginx) that is capable of
|
||||||
running [Symfony 6](https://symfony.com/doc/current/reference/requirements.html),
|
running [Symfony 7](https://symfony.com/doc/current/reference/requirements.html),
|
||||||
this includes a minimum PHP version of **PHP 8.2**
|
this includes a minimum PHP version of **PHP 8.2**
|
||||||
* A **MySQL** (at least 5.7) /**MariaDB** (at least 10.4) database server, or **PostgreSQL** 10+ if you do not want to use SQLite.
|
* A **MySQL** (at least 5.7) /**MariaDB** (at least 10.4) database server, or **PostgreSQL** 10+ if you do not want to use SQLite.
|
||||||
* Shell access to your server is highly recommended!
|
* Shell access to your server is highly recommended!
|
||||||
* For building the client-side assets **yarn** and **nodejs** (>= 20.0) is needed.
|
* For building the client-side assets **yarn** and **nodejs** (>= 22.0) is needed.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
||||||
979
composer.lock
generated
979
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -105,6 +105,8 @@ parameters:
|
||||||
|
|
||||||
env(DATABASE_EMULATE_NATURAL_SORT): 0
|
env(DATABASE_EMULATE_NATURAL_SORT): 0
|
||||||
|
|
||||||
|
env(ALLOW_ATTACHMENT_DOWNLOADS_FROM_LOCALNETWORK): 0
|
||||||
|
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
# Bulk Info Provider Import Configuration
|
# Bulk Info Provider Import Configuration
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
|
|
|
||||||
|
|
@ -1550,7 +1550,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||||
* template_parameters?: array{ // Default parameters to be passed to the template
|
* template_parameters?: array{ // Default parameters to be passed to the template
|
||||||
* className?: scalar|Param|null, // Default class attribute to apply to the root table elements // Default: "table table-bordered"
|
* className?: scalar|Param|null, // Default class attribute to apply to the root table elements // Default: "table table-bordered"
|
||||||
* columnFilter?: "thead"|"tfoot"|"both"|Param|null, // If and where to enable the DataTables Filter module // Default: null
|
* columnFilter?: "thead"|"tfoot"|"both"|Param|null, // If and where to enable the DataTables Filter module // Default: null
|
||||||
* ...<mixed>
|
* ...<string, mixed>
|
||||||
* },
|
* },
|
||||||
* translation_domain?: scalar|Param|null, // Default translation domain to be used // Default: "messages"
|
* translation_domain?: scalar|Param|null, // Default translation domain to be used // Default: "messages"
|
||||||
* }
|
* }
|
||||||
|
|
@ -1705,14 +1705,14 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||||
* use_underscore?: bool|Param, // Default: true
|
* use_underscore?: bool|Param, // Default: true
|
||||||
* unordered_list_markers?: list<scalar|Param|null>,
|
* unordered_list_markers?: list<scalar|Param|null>,
|
||||||
* },
|
* },
|
||||||
* ...<mixed>
|
* ...<string, mixed>
|
||||||
* },
|
* },
|
||||||
* }
|
* }
|
||||||
* @psalm-type GregwarCaptchaConfig = array{
|
* @psalm-type GregwarCaptchaConfig = array{
|
||||||
* length?: scalar|Param|null, // Default: 5
|
* length?: scalar|Param|null, // Default: 5
|
||||||
* width?: scalar|Param|null, // Default: 130
|
* width?: scalar|Param|null, // Default: 130
|
||||||
* height?: scalar|Param|null, // Default: 50
|
* height?: scalar|Param|null, // Default: 50
|
||||||
* font?: scalar|Param|null, // Default: "E:\\PHP\\Part-DB-server\\vendor\\gregwar\\captcha-bundle\\DependencyInjection/../Generator/Font/captcha.ttf"
|
* font?: scalar|Param|null, // Default: "/home/jan/php/Part-DB-server/vendor/gregwar/captcha-bundle/DependencyInjection/../Generator/Font/captcha.ttf"
|
||||||
* keep_value?: scalar|Param|null, // Default: false
|
* keep_value?: scalar|Param|null, // Default: false
|
||||||
* charset?: scalar|Param|null, // Default: "abcdefhjkmnprstuvwxyz23456789"
|
* charset?: scalar|Param|null, // Default: "abcdefhjkmnprstuvwxyz23456789"
|
||||||
* as_file?: scalar|Param|null, // Default: false
|
* as_file?: scalar|Param|null, // Default: false
|
||||||
|
|
@ -2649,7 +2649,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||||
* cast_fn?: mixed,
|
* cast_fn?: mixed,
|
||||||
* default?: mixed,
|
* default?: mixed,
|
||||||
* filter_class?: mixed,
|
* filter_class?: mixed,
|
||||||
* ...<mixed>
|
* ...<string, mixed>
|
||||||
* }>,
|
* }>,
|
||||||
* strict_query_parameter_validation?: mixed,
|
* strict_query_parameter_validation?: mixed,
|
||||||
* hide_hydra_operation?: mixed,
|
* hide_hydra_operation?: mixed,
|
||||||
|
|
@ -2669,7 +2669,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||||
* name?: mixed,
|
* name?: mixed,
|
||||||
* allow_create?: mixed,
|
* allow_create?: mixed,
|
||||||
* item_uri_template?: mixed,
|
* item_uri_template?: mixed,
|
||||||
* ...<mixed>
|
* ...<string, mixed>
|
||||||
* },
|
* },
|
||||||
* }
|
* }
|
||||||
* @psalm-type ConfigType = array{
|
* @psalm-type ConfigType = array{
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ bundled with Part-DB. Set `DATABASE_MYSQL_SSL_VERIFY_CERT` if you want to accept
|
||||||
* `ATTACHMENT_DOWNLOAD_BY_DEFAULT`: When this is set to 1, the "download external file" checkbox is checked by default
|
* `ATTACHMENT_DOWNLOAD_BY_DEFAULT`: When this is set to 1, the "download external file" checkbox is checked by default
|
||||||
when adding a new attachment. Otherwise, it is unchecked by default. Use this if you wanna download all attachments
|
when adding a new attachment. Otherwise, it is unchecked by default. Use this if you wanna download all attachments
|
||||||
locally by default. Attachment download is only possible, when `ALLOW_ATTACHMENT_DOWNLOADS` is set to 1.
|
locally by default. Attachment download is only possible, when `ALLOW_ATTACHMENT_DOWNLOADS` is set to 1.
|
||||||
|
* `ALLOW_ATTACHMENT_DOWNLOADS_FROM_LOCALNETWORK` (default `0`): When this is set to 1, users can make Part-DB directly download a file specified as a URL from the local network and create it as a local file. This allows users access to all resources available in the local network, which could be a security risk, so use this only if you trust your users and have a secure local network.
|
||||||
* `ATTACHMENT_SHOW_HTML_FILES`: When enabled, user uploaded HTML attachments can be viewed directly in the browser.
|
* `ATTACHMENT_SHOW_HTML_FILES`: When enabled, user uploaded HTML attachments can be viewed directly in the browser.
|
||||||
Many potential malicious functions are restricted, still this is a potential security risk and should only be enabled,
|
Many potential malicious functions are restricted, still this is a potential security risk and should only be enabled,
|
||||||
if you trust the users who can upload files. When set to 0, HTML files are rendered as plain text.
|
if you trust the users who can upload files. When set to 0, HTML files are rendered as plain text.
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ services:
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{: .warning }
|
||||||
|
> If you run a root console inside the docker container, and wanna execute commands on the webserver behalf, be sure to use `sudo -E` command (with the `-E` flag) to preserve env variables from the current shell.
|
||||||
|
> Otherwise Part-DB console might use the wrong configuration to execute commands.
|
||||||
|
|
||||||
|
|
||||||
6. Create the initial database with
|
6. Create the initial database with
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ fulfilled by the official Part-DB docker image.*
|
||||||
|
|
||||||
Part-DB 2.0 requires at least PHP 8.2 (newer versions are recommended). So if your existing Part-DB installation is still
|
Part-DB 2.0 requires at least PHP 8.2 (newer versions are recommended). So if your existing Part-DB installation is still
|
||||||
running PHP 8.1, you will have to upgrade your PHP version first.
|
running PHP 8.1, you will have to upgrade your PHP version first.
|
||||||
The minimum required version of node.js is now 20.0 or newer, so if you are using 18.0, you will have to upgrade it too.
|
The minimum required version of node.js is now 22.0 or newer, so if you are using 18.0, you will have to upgrade it too.
|
||||||
|
|
||||||
Most distributions should have the possibility to get backports for PHP 8.4 and modern nodejs, so you should be able to
|
Most distributions should have the possibility to get backports for PHP 8.4 and modern nodejs, so you should be able to
|
||||||
easily upgrade your system to the new requirements. Otherwise, you can use the official Part-DB docker image, which
|
easily upgrade your system to the new requirements. Otherwise, you can use the official Part-DB docker image, which
|
||||||
|
|
@ -60,6 +60,8 @@ The `php bin/console partdb:backup` command can help you with this.
|
||||||
If you want to change them, you must migrate them to the settings interface as described below.
|
If you want to change them, you must migrate them to the settings interface as described below.
|
||||||
|
|
||||||
### Docker installation
|
### Docker installation
|
||||||
|
**When running the console commands from inside a docker container's shell as root, be sure to use `sudo -E` to preserve the environment variables, so that they are correctly passed to the command.**
|
||||||
|
|
||||||
1. Make a backup of your existing Part-DB installation, including the database, data directories and the configuration files and the file where you configure the docker environment variables.
|
1. Make a backup of your existing Part-DB installation, including the database, data directories and the configuration files and the file where you configure the docker environment variables.
|
||||||
2. Stop the existing Part-DB container with `docker compose down`
|
2. Stop the existing Part-DB container with `docker compose down`
|
||||||
3. Ensure that your docker compose file uses the new latest images (either `latest` or `2` tag).
|
3. Ensure that your docker compose file uses the new latest images (either `latest` or `2` tag).
|
||||||
|
|
|
||||||
18
package.json
18
package.json
|
|
@ -9,16 +9,16 @@
|
||||||
"@symfony/stimulus-bridge": "^4.0.0",
|
"@symfony/stimulus-bridge": "^4.0.0",
|
||||||
"@symfony/ux-translator": "file:vendor/symfony/ux-translator/assets",
|
"@symfony/ux-translator": "file:vendor/symfony/ux-translator/assets",
|
||||||
"@symfony/ux-turbo": "file:vendor/symfony/ux-turbo/assets",
|
"@symfony/ux-turbo": "file:vendor/symfony/ux-turbo/assets",
|
||||||
"@symfony/webpack-encore": "^5.1.0",
|
"@symfony/webpack-encore": "^6.0.0",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.1.3",
|
||||||
"core-js": "^3.38.0",
|
"core-js": "^3.38.0",
|
||||||
"intl-messageformat": "^10.2.5",
|
"intl-messageformat": "^10.5.11",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"popper.js": "^1.14.7",
|
"popper.js": "^1.14.7",
|
||||||
"regenerator-runtime": "^0.13.9",
|
"regenerator-runtime": "^0.14.1",
|
||||||
"webpack": "^5.74.0",
|
"webpack": "^5.74.0",
|
||||||
"webpack-bundle-analyzer": "^5.1.1",
|
"webpack-bundle-analyzer": "^5.1.1",
|
||||||
"webpack-cli": "^5.1.0",
|
"webpack-cli": "^6.0.0",
|
||||||
"webpack-notifier": "^1.15.0"
|
"webpack-notifier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
|
|
@ -30,14 +30,14 @@
|
||||||
"build": "encore production --progress"
|
"build": "encore production --progress"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=22.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@algolia/autocomplete-js": "^1.17.0",
|
"@algolia/autocomplete-js": "^1.17.0",
|
||||||
"@algolia/autocomplete-plugin-recent-searches": "^1.17.0",
|
"@algolia/autocomplete-plugin-recent-searches": "^1.17.0",
|
||||||
"@algolia/autocomplete-theme-classic": "^1.17.0",
|
"@algolia/autocomplete-theme-classic": "^1.17.0",
|
||||||
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
|
"@ckeditor/ckeditor5-dev-translations": "^53",
|
||||||
"@ckeditor/ckeditor5-dev-utils": "^43.0.1",
|
"@ckeditor/ckeditor5-dev-utils": "^53",
|
||||||
"@jbtronics/bs-treeview": "^1.0.1",
|
"@jbtronics/bs-treeview": "^1.0.1",
|
||||||
"@part-db/html5-qrcode": "^4.0.0",
|
"@part-db/html5-qrcode": "^4.0.0",
|
||||||
"@zxcvbn-ts/core": "^3.0.2",
|
"@zxcvbn-ts/core": "^3.0.2",
|
||||||
|
|
@ -69,11 +69,11 @@
|
||||||
"marked": "^17.0.1",
|
"marked": "^17.0.1",
|
||||||
"marked-gfm-heading-id": "^4.1.1",
|
"marked-gfm-heading-id": "^4.1.1",
|
||||||
"marked-mangle": "^1.0.1",
|
"marked-mangle": "^1.0.1",
|
||||||
"pdfmake": "^0.2.2",
|
"pdfmake": "^0.3.7",
|
||||||
"stimulus-use": "^0.52.0",
|
"stimulus-use": "^0.52.0",
|
||||||
"tom-select": "^2.1.0",
|
"tom-select": "^2.1.0",
|
||||||
"ts-loader": "^9.2.6",
|
"ts-loader": "^9.2.6",
|
||||||
"typescript": "^5.7.2"
|
"typescript": "^6.0.2"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"jquery": "^3.5.1"
|
"jquery": "^3.5.1"
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,16 @@ class LoadFixturesCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$factory = new ResetAutoIncrementPurgerFactory();
|
$factory = new ResetAutoIncrementPurgerFactory();
|
||||||
$purger = $factory->createForEntityManager(null, $this->entityManager);
|
|
||||||
|
//Use truncate purging to fix compatibility with postgresql
|
||||||
|
$purger = $factory->createForEntityManager(null, $this->entityManager, purgeWithTruncate: true);
|
||||||
|
|
||||||
$purger->purge();
|
$purger->purge();
|
||||||
|
|
||||||
//Afterwards run the load fixtures command as normal, but with the --append option
|
//Afterwards run the load fixtures command as normal, but with the --append option
|
||||||
$new_input = new ArrayInput([
|
$new_input = new ArrayInput([
|
||||||
'command' => 'doctrine:fixtures:load',
|
'command' => 'doctrine:fixtures:load',
|
||||||
|
'--purge-with-truncate' => true,
|
||||||
'--append' => true,
|
'--append' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ class TypeSynonymRowType extends AbstractType
|
||||||
*/
|
*/
|
||||||
private function getPreferredLocales(): array
|
private function getPreferredLocales(): array
|
||||||
{
|
{
|
||||||
$fromSettings = $this->localizationSettings->languageMenuEntries ?? [];
|
$fromSettings = $this->localizationSettings->languageMenuEntries;
|
||||||
return !empty($fromSettings) ? array_values($fromSettings) : array_values($this->preferredLanguagesParam);
|
return !empty($fromSettings) ? array_values($fromSettings) : array_values($this->preferredLanguagesParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ use App\Exceptions\AttachmentDownloadException;
|
||||||
use App\Settings\SystemSettings\AttachmentsSettings;
|
use App\Settings\SystemSettings\AttachmentsSettings;
|
||||||
use Hshn\Base64EncodedFile\HttpFoundation\File\Base64EncodedFile;
|
use Hshn\Base64EncodedFile\HttpFoundation\File\Base64EncodedFile;
|
||||||
use Hshn\Base64EncodedFile\HttpFoundation\File\UploadedBase64EncodedFile;
|
use Hshn\Base64EncodedFile\HttpFoundation\File\UploadedBase64EncodedFile;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
|
use Symfony\Component\HttpClient\NoPrivateNetworkHttpClient;
|
||||||
use const DIRECTORY_SEPARATOR;
|
use const DIRECTORY_SEPARATOR;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
@ -76,6 +78,8 @@ class AttachmentSubmitHandler
|
||||||
protected FileTypeFilterTools $filterTools,
|
protected FileTypeFilterTools $filterTools,
|
||||||
protected AttachmentsSettings $settings,
|
protected AttachmentsSettings $settings,
|
||||||
protected readonly SVGSanitizer $SVGSanitizer,
|
protected readonly SVGSanitizer $SVGSanitizer,
|
||||||
|
#[Autowire(env: "bool:ALLOW_ATTACHMENT_DOWNLOADS_FROM_LOCALNETWORK")]
|
||||||
|
private readonly bool $allow_local_network_downloads = false,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//The mapping used to determine which folder will be used for an attachment type
|
//The mapping used to determine which folder will be used for an attachment type
|
||||||
|
|
@ -95,6 +99,10 @@ class AttachmentSubmitHandler
|
||||||
UserAttachment::class => 'user',
|
UserAttachment::class => 'user',
|
||||||
LabelAttachment::class => 'label_profile',
|
LabelAttachment::class => 'label_profile',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!$this->allow_local_network_downloads) {
|
||||||
|
$this->httpClient = new NoPrivateNetworkHttpClient($this->httpClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -373,6 +381,7 @@ class AttachmentSubmitHandler
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->httpClient->request('GET', $url, $opts);
|
$response = $this->httpClient->request('GET', $url, $opts);
|
||||||
//Digikey wants TLSv1.3, so try again with that if we get a 403
|
//Digikey wants TLSv1.3, so try again with that if we get a 403
|
||||||
if ($response->getStatusCode() === 403) {
|
if ($response->getStatusCode() === 403) {
|
||||||
|
|
@ -434,8 +443,8 @@ class AttachmentSubmitHandler
|
||||||
$new_path = $this->pathResolver->realPathToPlaceholder($new_path);
|
$new_path = $this->pathResolver->realPathToPlaceholder($new_path);
|
||||||
//Save the path to the attachment
|
//Save the path to the attachment
|
||||||
$attachment->setInternalPath($new_path);
|
$attachment->setInternalPath($new_path);
|
||||||
} catch (TransportExceptionInterface) {
|
} catch (TransportExceptionInterface $exception) {
|
||||||
throw new AttachmentDownloadException('Transport error!');
|
throw new AttachmentDownloadException('Transport error: '.$exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $attachment;
|
return $attachment;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ use Brick\Schema\Interfaces\Thing;
|
||||||
use Brick\Schema\SchemaReader;
|
use Brick\Schema\SchemaReader;
|
||||||
use Brick\Schema\SchemaTypeList;
|
use Brick\Schema\SchemaTypeList;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
|
use Symfony\Component\HttpClient\NoPrivateNetworkHttpClient;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
class GenericWebProvider implements InfoProviderInterface
|
class GenericWebProvider implements InfoProviderInterface
|
||||||
|
|
@ -55,7 +56,8 @@ class GenericWebProvider implements InfoProviderInterface
|
||||||
private readonly ProviderRegistry $providerRegistry, private readonly PartInfoRetriever $infoRetriever,
|
private readonly ProviderRegistry $providerRegistry, private readonly PartInfoRetriever $infoRetriever,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->httpClient = (new RandomizeUseragentHttpClient($httpClient))->withOptions(
|
//Use NoPrivateNetworkHttpClient to prevent SSRF vulnerabilities, and RandomizeUseragentHttpClient to make it harder for servers to block us
|
||||||
|
$this->httpClient = (new RandomizeUseragentHttpClient(new NoPrivateNetworkHttpClient($httpClient)))->withOptions(
|
||||||
[
|
[
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue