-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lucas Gracioso <[email protected]>
- Loading branch information
1 parent
ab432bb
commit 585aeea
Showing
2 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
// EL8 KEYS | ||
const std::string GPG_KEY_ALMA_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-AlmaLinux" | ||
; | ||
|
||
const std::string GPG_KEY_BEEGFS_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-beegfs" | ||
; | ||
|
||
const std::string GPG_KEY_ELREPO_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-elrepo" | ||
; | ||
|
||
const std::string GPG_KEY_EPEL_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-epel" | ||
; | ||
|
||
const std::string GPG_KEY_GRAFANA_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-grafana" | ||
; | ||
|
||
const std::string GPG_KEY_INFLUXDATA_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-influxdata" | ||
; | ||
|
||
const std::string GPG_KEY_ONEAPI_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-oneapi" | ||
; | ||
|
||
const std::string GPG_KEY_OPENHPC_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-openhpc" | ||
; | ||
|
||
const std::string GPG_KEY_ORACLE_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-oracle" | ||
; | ||
|
||
const std::string GPG_KEY_RHEL_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-rhel-unavailable" | ||
|
||
const std::string GPG_KEY_ROCKY_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-rockyofficial" | ||
; | ||
|
||
const std::string GPG_KEY_RPMFUSIONUPDATES_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-rpmfusion-updates" | ||
; | ||
|
||
const std::string GPG_KEY_ZABBIX_8 = | ||
#include "cloysterhpc/repos/offline/el8/RPM-GPG-KEY-zabbix" | ||
; | ||
|
||
// EL9 KEYS | ||
const std::string GPG_KEY_ALMA_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-AlmaLinux" | ||
; | ||
|
||
const std::string GPG_KEY_BEEGFS_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-beegfs" | ||
; | ||
|
||
const std::string GPG_KEY_ELREPO_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-elrepo" | ||
; | ||
|
||
const std::string GPG_KEY_EPEL_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-epel" | ||
; | ||
|
||
const std::string GPG_KEY_GRAFANA_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-grafana" | ||
; | ||
|
||
const std::string GPG_KEY_INFLUXDATA_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-influxdata" | ||
; | ||
|
||
const std::string GPG_KEY_ONEAPI_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-oneapi" | ||
; | ||
|
||
const std::string GPG_KEY_OPENHPC_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-openhpc" | ||
; | ||
|
||
const std::string GPG_KEY_ORACLE_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-oracle" | ||
; | ||
|
||
const std::string GPG_KEY_RHEL_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-rhel-unavailable" | ||
|
||
const std::string GPG_KEY_ROCKY_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-rockyofficial" | ||
; | ||
|
||
const std::string GPG_KEY_RPMFUSIONUPDATES_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-rpmfusion-updates" | ||
; | ||
|
||
const std::string GPG_KEY_ZABBIX_9 = | ||
#include "cloysterhpc/repos/offline/el9/RPM-GPG-KEY-zabbix" | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Created by Lucas Gracioso <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef CLOYSTERHPC_GPGTOOLS_H_ | ||
#define CLOYSTERHPC_GPGTOOLS_H_ | ||
|
||
#include "gpgkeys.h" | ||
#include <algorithm> | ||
#include <fmt/format.h> | ||
#include <map> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
enum class AddonType { | ||
beegfs, | ||
ELRepo, | ||
EPEL, | ||
Grafana, | ||
influxData, | ||
oneAPI, | ||
OpenHPC, | ||
Zabbix, | ||
RPMFusionUpdates | ||
}; | ||
|
||
enum class Platform { el8, el9 }; | ||
|
||
class GPGVerifier { | ||
protected: | ||
std::multimap<AddonType, std::pair<Platform, std::string>> m_gpg_keys; | ||
|
||
public: | ||
GPGVerifier() | ||
: m_gpg_keys{ | ||
{ AddonType::beegfs, { Platform::el8, GPG_KEY_BEEGFS_8 }}, | ||
{ AddonType::beegfs, { Platform::el9, GPG_KEY_BEEGFS_9 }}, | ||
{ AddonType::ELRepo, { Platform::el8, GPG_KEY_ELREPO_8 }}, | ||
{ AddonType::ELRepo, { Platform::el9, GPG_KEY_ELREPO_9 }}, | ||
{ AddonType::EPEL, { Platform::el8, GPG_KEY_EPEL_8 }}, | ||
{ AddonType::EPEL, { Platform::el9, GPG_KEY_EPEL_9 }}, | ||
{ AddonType::Grafana, { Platform::el8, GPG_KEY_GRAFANA_8 }}, | ||
{ AddonType::Grafana, { Platform::el9, GPG_KEY_GRAFANA_9 }}, | ||
{ AddonType::influxData, { Platform::el8, GPG_KEY_INFLUXDATA_8 }}, | ||
{ AddonType::influxData, { Platform::el9, GPG_KEY_INFLUXDATA_9 }}, | ||
{ AddonType::oneAPI, { Platform::el8, GPG_KEY_ONEAPI_8 }}, | ||
{ AddonType::oneAPI, { Platform::el9, GPG_KEY_ONEAPI_9 }}, | ||
{ AddonType::OpenHPC, { Platform::el8, GPG_KEY_OPENHPC_8 }}, | ||
{ AddonType::OpenHPC, { Platform::el9, GPG_KEY_OPENHPC_9 }}, | ||
{ AddonType::RPMFusionUpdates, { Platform::el8, GPG_KEY_RPMFUSIONUPDATES_8 }}, | ||
{ AddonType::RPMFusionUpdates, { Platform::el9, GPG_KEY_RPMFUSIONUPDATES_9 }}, | ||
{ AddonType::Zabbix, { Platform::el8, GPG_KEY_ZABBIX_8 }}, | ||
{ AddonType::Zabbix, { Platform::el9, GPG_KEY_ZABBIX_9 }} | ||
} | ||
{} | ||
|
||
std::vector<std::pair<Platform, std::string>> getGPGKeys(AddonType type) | ||
{ | ||
std::vector<std::pair<Platform, std::string>> result; | ||
|
||
auto range = m_gpg_keys.equal_range(type); | ||
for (auto it = range.first; it != range.second; ++it) { | ||
result.push_back(it->second); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
bool verifyGPGKey(AddonType type, Platform platform, const std::string& gpgKey) | ||
{ | ||
auto range = m_gpg_keys.equal_range(type); | ||
for (auto it = range.first; it != range.second; ++it) { | ||
if (it->second.first == platform && it->second.second == gpgKey) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
}; | ||
|
||
#endif // CLOYSTERHPC_GPGTOOLS_H_ |