Skip to content

Commit

Permalink
Merge pull request #596 from alma/chore/backport-main-to-develop
Browse files Browse the repository at this point in the history
Backport main to develop
  • Loading branch information
Benjamin-Freoua-Alma authored Oct 30, 2024
2 parents ad0cf10 + 0828e39 commit c23d862
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 49 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/aqua.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Aqua

on:
pull_request:
branches:
Expand All @@ -7,25 +8,43 @@ on:

jobs:
aqua:
name: Aqua scanner
name: Code scanning
runs-on: ubuntu-24.04

permissions:
contents: read
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
show-progress: false

- name: Authenticate to Google Cloud
id: gcloud-auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: projects/699052769907/locations/global/workloadIdentityPools/github-identity-pool-shared/providers/github-identity-provider-shared # yamllint disable-line
service_account: github-gar-alma-installments-p@lyrical-carver-335213.iam.gserviceaccount.com

- name: Authenticate to Artifact Registry
uses: docker/login-action@v3
with:
registry: europe-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcloud-auth.outputs.access_token }}

- name: Run Aqua scanner
uses: docker://aquasec/aqua-scanner
with:
args: trivy fs --sast --reachability --scanners misconfig,vuln,secret .
# To customize which severities add the following flag: --severity UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
# To enable SAST scanning, add: --sast
# To enable reachability scanning, add: --reachability
# To enable npm/dotnet non-lock file scanning, add: --package-json / --dotnet-proj
env:
AQUA_KEY: ${{ secrets.AQUA_KEY }}
AQUA_SECRET: ${{ secrets.AQUA_SECRET }}
GITHUB_TOKEN: ${{ github.token }}
AQUA_URL: https://api.eu-1.supply-chain.cloud.aquasec.com
CSPM_URL: https://eu-1.api.cloudsploit.com
TRIVY_RUN_AS_PLUGIN: "aqua"
# For http/https proxy configuration add env vars: HTTP_PROXY/HTTPS_PROXY, CA-CRET (path to CA certificate)
TRIVY_RUN_AS_PLUGIN: aqua
TRIVY_DB_REPOSITORY: europe-docker.pkg.dev/lyrical-carver-335213/ghcr-remote-cache/aquasecurity/trivy-db:2
with:
args: trivy fs --sast --reachability --scanners misconfig,vuln,secret .
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v4.4.1 - 2024-10-30

### 🐛 Bug Fixes

fix: Error configuration module with ps_accounts lower than 5.3.0

## v4.4.0 - 2024-10-07

### Changes
Expand Down
61 changes: 42 additions & 19 deletions alma/alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

class Alma extends PaymentModule
{
const VERSION = '4.4.0';
const VERSION = '4.4.1';
const PS_ACCOUNTS_VERSION_REQUIRED = '5.3.0';

public $_path;
public $local_path;
Expand Down Expand Up @@ -80,7 +81,7 @@ public function __construct()
{
$this->name = 'alma';
$this->tab = 'payments_gateways';
$this->version = '4.4.0';
$this->version = '4.4.1';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down Expand Up @@ -128,24 +129,45 @@ public function __construct()
/**
* @return void
*
* @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException
* @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException
*/
public function checkCompatibilityPSModule()
public function checkPsAccountsPresence()
{
if (_PS_MODE_DEV_ === true) {
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Debug mode is activated');
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Debug mode is activated');
}

if (
!class_exists(\Symfony\Component\Config\ConfigCache::class)
|| !class_exists(\PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer::class)
) {
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Classes don\'t exist for PS Account');
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Classes don\'t exist for PS Account');
}
if (
$this->toolsHelper->psVersionCompare('1.6', '<')
) {
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Prestashop version lower than 1.6');
throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Prestashop version lower than 1.6');
}
}

/**
* Check if PS Account is installed and up to date, minimal version required 5.0.
*
* @return void
*
* @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException
* @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException
*/
public function checkPsAccountsCompatibility()
{
$this->checkPsAccountsPresence();
$psAccountsModule = \Module::getInstanceByName('ps_accounts');
if (!$psAccountsModule) {
throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not installed');
}

if ($psAccountsModule->version < self::PS_ACCOUNTS_VERSION_REQUIRED) {
throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not up to date, minimal version required ' . self::PS_ACCOUNTS_VERSION_REQUIRED);
}
}

Expand Down Expand Up @@ -222,10 +244,10 @@ private function checkCoreInstall($coreInstall)
public function install()
{
try {
$this->checkCompatibilityPSModule();
$this->checkPsAccountsPresence();
$this->setContainer();
$this->getService('alma.ps_accounts_installer')->install();
} catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountException $e) {
} catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException $e) {
\Alma\PrestaShop\Logger::instance()->info($e->getMessage());
}

Expand Down Expand Up @@ -586,28 +608,29 @@ public function viewAccess()
*/
public function getContent()
{
$suggestPSAccount = false;
$suggestPSAccounts = false;

try {
$hasPSAccount = $this->renderPSAccount();
} catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountException $e) {
$hasPSAccount = false;
$hasPSAccounts = $this->renderPSAccounts();
} catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException $e) {
$hasPSAccounts = false;
} catch (\PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException $e) {
$hasPSAccount = false;
$suggestPSAccount = true;
$hasPSAccounts = false;
$suggestPSAccounts = true;
}

return $this->runHookController('getContent', ['hasPSAccount' => $hasPSAccount, 'suggestPSAccount' => $suggestPSAccount]);
return $this->runHookController('getContent', ['hasPSAccounts' => $hasPSAccounts, 'suggestPSAccounts' => $suggestPSAccounts]);
}

/**
* @return bool
*
* @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException
* @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException
* @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException
*/
public function renderPSAccount()
public function renderPSAccounts()
{
$this->checkCompatibilityPSModule();
$this->checkPsAccountsCompatibility();
$this->setContainer();

try {
Expand Down
12 changes: 6 additions & 6 deletions alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function processConfiguration()
if ((empty($liveKey) && ALMA_MODE_LIVE == $apiMode) || (empty($testKey) && ALMA_MODE_TEST == $apiMode)) {
$this->context->smarty->assign('validation_error', "missing_key_for_{$apiMode}_mode");
$this->context->smarty->assign([
'suggestPSAccount' => false,
'suggestPSAccounts' => false,
]);

$this->hasKey = false;
Expand Down Expand Up @@ -542,8 +542,8 @@ public function renderForm()

$this->assignSmartyAlertClasses();
$this->context->smarty->assign('tip', 'fill_api_keys');
$this->context->smarty->assign('suggestPSAccount', false);
$this->context->smarty->assign('hasPSAccount', false);
$this->context->smarty->assign('suggestPSAccounts', false);
$this->context->smarty->assign('hasPSAccounts', false);

$extraMessage = $this->module->display($this->module->file, 'getContent.tpl');
}
Expand Down Expand Up @@ -833,9 +833,9 @@ public function needsAPIKey()
public function run($params)
{
$this->context->smarty->assign([
'hasPSAccount' => $params['hasPSAccount'],
'hasPSAccounts' => $params['hasPSAccounts'],
'updated' => true,
'suggestPSAccount' => $params['suggestPSAccount'],
'suggestPSAccounts' => $params['suggestPSAccounts'],
]);

$this->assignSmartyAlertClasses();
Expand Down Expand Up @@ -867,7 +867,7 @@ public function run($params)
$messages = '';
}

if ($params['hasPSAccount'] || $params['suggestPSAccount']) {
if ($params['hasPSAccounts'] || $params['suggestPSAccounts']) {
$messages = $this->module->display($this->module->file, 'getContent.tpl');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
exit;
}

class CompatibilityPsAccountException extends AlmaException
class CompatibilityPsAccountsException extends AlmaException
{
}
3 changes: 2 additions & 1 deletion alma/translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Enter your API key';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Find your API live key on your %1$s Alma dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Um den Testmodus zu verwenden, rufen Sie Ihren Test-API-Schlüssel von Ihrem %1$ssandbox dashboard%2$s ab.';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Wir bieten das PrestaShop Account Modul zum Download an';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Wir bieten Ihnen an, das PrestaShop Account-Modul herunterzuladen oder zu aktualisieren (mindestens erforderliche Version %1$s)';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Verknüpfen Sie Ihren Shop mit Ihrem PrestaShop-Konto, um alle Vorteile der vom PrestaShop Marketplace angebotenen Module zu nutzen und Ihre Erfahrungen zu optimieren.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Das Modul %1$sfinden Sie hier%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Steigern Sie Ihre Leistung und erhalten Sie Einblicke!';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Indem Sie diese Option akzeptieren, ermöglichen Sie es Alma, die Nutzung Ihrer Zahlungsmittel zu analysieren, [1]mehr Informationen zu erhalten, um[/1] durchzuführen und diese Daten mit Ihnen zu teilen. Sie können [2]jederzeit abbestellen und Ihre Daten[/2] löschen.';
Expand Down
3 changes: 2 additions & 1 deletion alma/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Enter your API key';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Find your API live key on your %1$s Alma dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'To use Test mode, retrieve your Test API key from your %1$ssandbox dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'We offer to download the PrestaShop Account module';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'We offer to download or update the PrestaShop Account module (minimum required version %1$s)';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'You can find the module %1$shere%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Increase your performance & get insights !';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'By accepting this option, you enable Alma to analyse the usage of your payment methods, [1]get more information to perform[/1] and share this data with you. You can [2]unsubscribe and erase your data[/2] at any moment.';
Expand Down
3 changes: 2 additions & 1 deletion alma/translations/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Introduce tu clave API';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Encuentra tu API live key en tu %1$s Alma dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Para utilizar el modo de prueba, obtenga su clave de API de prueba en el panel de control de su sandbox %1$s%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Te proponemos descargar el módulo Cuenta PrestaShop';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Le ofrecemos descargar o actualizar el módulo Cuenta de PrestaShop (versión mínima requerida %1$s)';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Vincula tu tienda a tu cuenta PrestaShop para aprovechar al máximo los módulos que ofrece PrestaShop Marketplace y optimizar tu experiencia.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Encontrará el módulo %1$saquí%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Aumenta tu rendimiento y obtén información';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Al aceptar esta opción, permites a Alma analizar el uso de tus métodos de pago, [1]obtener más información para realizar[/1] y compartir estos datos contigo. Puedes [2]darte de baja y borrar tus datos[/2] en cualquier momento.';
Expand Down
3 changes: 2 additions & 1 deletion alma/translations/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Entrez votre clé API';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Trouvez votre clé API sur votre tableau de bord %1$s Alma%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Pour utiliser le mode test, récupérez votre clé API de test dans le tableau de bord de votre sandbox %1$s%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Nous vous proposons de télécharger le module PrestaShop Account';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Nous vous proposons de télécharger ou de mettre à jour le module PrestaShop Account (version minimale requise %1$s)';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Liez votre boutique à votre compte PrestaShop pour profiter pleinement des modules proposés par PrestaShop Marketplace et optimiser votre expérience.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Vous pouvez trouver le module %1$sici%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Augmentez vos performances et obtenez des informations !';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'En acceptant cette option, vous permettez à Alma d\'analyser l\'utilisation de vos moyens de paiement, [1]d\'obtenir plus d\'informations pour effectuer[/1] et de partager ces données avec vous. Vous pouvez à tout moment vous désinscrire [2]et effacer vos données[/2] .';
Expand Down
3 changes: 2 additions & 1 deletion alma/translations/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Inserire la chiave API';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Trovate la vostra chiave API live sul vostro cruscotto %1$s Alma%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Per utilizzare la modalità Test, recuperare la chiave API Test dalla dashboard di %1$ssandbox%2$s.';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Vi proponiamo di scaricare il modulo Account di PrestaShop';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Offriamo il download o l\'aggiornamento del modulo PrestaShop Account (versione minima richiesta %1$s).';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Collegate il vostro negozio al vostro account PrestaShop per sfruttare appieno i moduli offerti dal Marketplace PrestaShop e ottimizzare la vostra esperienza.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'È possibile trovare il modulo %1$squi%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = 'Aumenta le tue prestazioni e ricevi approfondimenti sulle tue vendite!';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Attivando questa opzione, permetti ad Alma di analizzare l\'utilizzo dei tuoi metodi di pagamento [1]al fine[/1] di migliorare il servizio e condividerti un approfondimento sui dati analizzati. Puoi [2]annullare l\'iscrizione e cancellare i tuoi dati[/2] in qualsiasi momento.';
Expand Down
3 changes: 2 additions & 1 deletion alma/translations/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
$_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Voer je API-sleutel in';
$_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Vind je API live key op je %1$s Alma dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Om de Testmodus te gebruiken, haalt je je Test API-sleutel op van jouw %1$ssandbox dashboard%2$s';
$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Wij bieden aan om de PrestaShop Account module te downloaden';
$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Wij bieden aan om de module PrestaShop Account te downloaden of bij te werken (minimaal vereiste versie %1$s)';
$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Koppel uw winkel aan uw PrestaShop-account om optimaal te profiteren van de modules die worden aangeboden door de PrestaShop Marketplace en optimaliseer uw ervaring.';
$_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Je kunt de module %1$shier vinden%2$s';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Verhoog je prestaties & krijg inzichten!';
$_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Door deze optie te aanvaarden, stel je Alma in staat het gebruik van je betaalmethoden te analyseren, [1]meer informatie te verkrijgen om beter te presteren[/1] en deze gegevens met jou te delen. Je kunt [2]je op elk moment uitschrijven en je data wissen[/2].';
Expand Down
Loading

0 comments on commit c23d862

Please sign in to comment.