diff --git a/src/Form/Admin.php b/src/Form/Admin.php index 9cfaa51..90febef 100644 --- a/src/Form/Admin.php +++ b/src/Form/Admin.php @@ -78,12 +78,17 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('islandora_spreadsheet_ingest.settings'); $current_whitelist = $config->get('binary_directory_whitelist'); + $scheme_options = $this->streamWrapperManager->getNames(StreamWrapperInterface::READ_VISIBLE) + [ + 'http' => 'HTTP', + 'https' => 'HTTPS', + 'ftp' => 'FTP', + ]; $form['schemes'] = [ '#type' => 'checkboxes', '#title' => $this->t('Schemes'), '#description' => $this->t('Allowed list of schemes for which binaries can be referenced from.'), '#default_value' => $config->get('schemes') ?? [], - '#options' => $this->streamWrapperManager->getNames(StreamWrapperInterface::READ_VISIBLE), + '#options' => $scheme_options, ]; $form['paths'] = [ '#type' => 'textarea', diff --git a/src/Plugin/migrate/process/AccessibleFile.php b/src/Plugin/migrate/process/AccessibleFile.php index df155e8..97b10d6 100644 --- a/src/Plugin/migrate/process/AccessibleFile.php +++ b/src/Plugin/migrate/process/AccessibleFile.php @@ -6,8 +6,10 @@ use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; +use Drupal\Core\Url; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipRowException; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -99,6 +101,20 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $allowed_paths = $this->configFactory->get('islandora_spreadsheet_ingest.settings')->get('binary_directory_whitelist'); $allowed_schemes = $this->configFactory->get('islandora_spreadsheet_ingest.settings')->get('schemes'); + // Ignore this check if relevant configuration has not been set, and advise + // that the configuration should be set. + if (empty($allowed_paths) && empty($allowed_schemes)) { + $migrate_executable->saveMessage( + strtr("File access criteria is not defined; passing check of file (:file). For site security, it is highly recommended to set appropriate configuration at :config_url.", [ + ':file' => $value, + ':config_url' => Url::fromRoute('islandora_spreadsheet_ingest.admin')->toString(), + ]), + MigrationInterface::MESSAGE_WARNING + ); + + return $value; + } + // If it's a local path check to see if it's in our allowed list. $file_path = $this->fileSystem->realpath($value); if ($file_path) {