Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Athena's Shield | The Extra File Verification System #364

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3ee4c73
Add documentation for Athena's Shield feature
Sandro642 Oct 23, 2024
9813802
Add Athena's Shield configuration and CLI
Sandro642 Oct 23, 2024
5f3e229
Add new dlAsync function and mod validation messages
Sandro642 Oct 23, 2024
3790b52
Update landing.js dependencies and add new features
Sandro642 Oct 24, 2024
85cb733
Fix typo in game launch message
Sandro642 Oct 24, 2024
7073c27
Add mod whitelist and new HeliosLauncher support
Sandro642 Oct 24, 2024
886b29e
Use AthShield for mod verification
Sandro642 Oct 24, 2024
1476dbb
Merge remote-tracking branch 'origin/master'
Sandro642 Oct 24, 2024
2fc9c3e
Add mod verification logic using Athena's Shield
Sandro642 Oct 24, 2024
b435f7a
Refactor project structure by moving athshield files
Sandro642 Oct 24, 2024
e3c6a18
Add Athena's Shield activation messages
Sandro642 Oct 24, 2024
ae9e7b5
Update athshield script path in package.json
Sandro642 Oct 24, 2024
fc5a2d4
Rename view method to type and integrate athShield in settings
Sandro642 Oct 24, 2024
96e0ca1
Refactor menu visibility logic in athshield.js
Sandro642 Oct 24, 2024
297a3a0
Refactor comments and questions from French to English
Sandro642 Oct 24, 2024
9d4c8cc
Fix escape character handling in console log messages
Sandro642 Oct 24, 2024
4835001
Refactor dataPath assignment
Sandro642 Oct 24, 2024
1f4df6b
Refactor config path retrieval in landing.js
Sandro642 Oct 24, 2024
980c836
Make package public
Sandro642 Oct 25, 2024
0964648
Add project configuration and settings files
Sandro642 Oct 26, 2024
3cdad51
Add debug mode option to Athena's Shield configuration
Sandro642 Oct 26, 2024
485facf
Enable debug logging conditionally for AthShield
Sandro642 Oct 26, 2024
33788d4
Update REMOTE_DISTRO_URL to new API endpoint
Sandro642 Oct 26, 2024
84b4ba9
Refactor identity check error message
Sandro642 Oct 26, 2024
f366b8b
Update distribution URL in distromanager.js
Sandro642 Oct 26, 2024
50ad0e8
Enable detailed debug logging for mod identity validation
Sandro642 Oct 26, 2024
a94aa49
Fix typo in comment annotation
Sandro642 Oct 26, 2024
1515571
Remove deprecated Athena Shield and HeliosLauncher code
Sandro642 Oct 26, 2024
db49984
Update documentation: Move Athena's Shield docs to /docs
Sandro642 Oct 26, 2024
1608983
Add crypto package to dependencies
Sandro642 Oct 26, 2024
a9c81a1
Update review date in landing.js header comment
Sandro642 Oct 26, 2024
d0c5bf1
Set package to private
Sandro642 Oct 26, 2024
5ffa732
Remove outdated .idea configuration files
Sandro642 Oct 26, 2024
068ca6b
Remove French configuration and distribution files
Sandro642 Oct 26, 2024
a8a00e4
Add Athena's Shield section to README
Sandro642 Oct 26, 2024
aab9ff5
Update launch process with Discord RPC enhancements
Sandro642 Oct 26, 2024
8744d3b
Remove unnecessary comment separators
Sandro642 Oct 26, 2024
0893cf5
Update landing script to improve debug capabilities
Sandro642 Oct 26, 2024
f0321e1
Reorder function calls in prepareModsTab.
Sandro642 Oct 26, 2024
0348e83
Refactor Athena's Shield configuration handling
Sandro642 Oct 27, 2024
f68165c
Refactor class name in parserExtraverif.js
Sandro642 Oct 27, 2024
040ca97
Refactor CLI activation logic and improve debug capabilities
Sandro642 Oct 27, 2024
aef5e02
Refactor mod verification logic and improve debug capabilities
Sandro642 Oct 27, 2024
1614b63
Refactor language file and update mod verification messages
Sandro642 Oct 27, 2024
93bca16
Refactor documentation and file names for mod verification
Sandro642 Oct 27, 2024
bd67015
Refactor package.json to update extraverif script
Sandro642 Oct 27, 2024
e51eefa
Refactor mod verification system and improve debug capabilities
Sandro642 Oct 27, 2024
745a11e
Refactor landing.js: Remove unnecessary blank lines and comments
Sandro642 Oct 27, 2024
4732ee5
Refactor landing.js: Update logger name in dlAsync function
Sandro642 Oct 27, 2024
d659e0f
Refactor README.md: Remove ExtraFileVerification section
Sandro642 Oct 27, 2024
07ed316
Refactor package.json: Remove unused crypto dependency
Sandro642 Oct 27, 2024
7f33a1d
Refactor landing.js: Update modIdentity assignment in dlAsync function
Sandro642 Oct 27, 2024
2f0a054
Refactor variables.json: Add newline at end of file
Sandro642 Oct 27, 2024
d4437c7
Update variables.json
Sandro642 Oct 28, 2024
0770d65
Refactor settings.js: Update variable and comment names in manageMods…
Sandro642 Oct 29, 2024
092f36a
Refactor variables.json: Add newline at end of file
Sandro642 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,42 @@ Builds for macOS may not work on Windows/Linux and vice-versa.

---

### Athena's Shield

The Extra File Verification System

Athena’s Shield prevents the use of unapproved mods in HeliosLauncher by verifying the integrity of each mod from the distribution, blocking unauthorized changes, and ensuring a secure, reliable gaming experience.

**How to active this ?**

```console
> npm run athshield
```

```
Would you like to activate Athena's Shield? (yes/no): yes
Would you like to activate debug mode? (yes/no): yes
Would you like to hide or block the menu? (hide/block): block

Athena's Shield activated. Menu blocked.
```

You can choose whether Athena's Shield hides the mod category or blocks interaction with the drop-in mod.

```console
▄▄▄ ▄▄▄█████▓ ██░ ██ ▓█████ ███▄ █ ▄▄▄ ██████ ██████ ██░ ██ ██▓▓█████ ██▓ ▓█████▄
▒████▄ ▓ ██▒ ▓▒▓██░ ██▒▓█ ▀ ██ ▀█ █ ▒████▄ ▒██ ▒ ▒██ ▒ ▓██░ ██▒▓██▒▓█ ▀ ▓██▒ ▒██▀ ██▌
▒██ ▀█▄ ▒ ▓██░ ▒░▒██▀▀██░▒███ ▓██ ▀█ ██▒▒██ ▀█▄ ░ ▓██▄ ░ ▓██▄ ▒██▀▀██░▒██▒▒███ ▒██░ ░██ █▌
░██▄▄▄▄██░ ▓██▓ ░ ░▓█ ░██ ▒▓█ ▄ ▓██▒ ▐▌██▒░██▄▄▄▄██ ▒ ██▒ ▒ ██▒░▓█ ░██ ░██░▒▓█ ▄ ▒██░ ░▓█▄ ▌
▓█ ▓██▒ ▒██▒ ░ ░▓█▒░██▓░▒████▒▒██░ ▓██░ ▓█ ▓██▒▒██████▒▒ ▒██████▒▒░▓█▒░██▓░██░░▒████▒░██████▒░▒████▓
▒▒ ▓▒█░ ▒ ░░ ▒ ░░▒░▒░░ ▒░ ░░ ▒░ ▒ ▒ ▒▒ ▓▒█░▒ ▒▓▒ ▒ ░ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒░▓ ░░ ▒░ ░░ ▒░▓ ░ ▒▒▓ ▒
▒ ▒▒ ░ ░ ▒ ░▒░ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ▒▒ ░░ ░▒ ░ ░ ░ ░▒ ░ ░ ▒ ░▒░ ░ ▒ ░ ░ ░ ░░ ░ ▒ ░ ░ ▒ ▒
░ ▒ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
```

---

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this belongs in the readme. I'd put it either in the docs folder, or in the wiki

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour ça si le code sera merge il faudra le faire mais pour l'instant je ne peux pas

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that, if the code is going to be merged, it will have to be done, but for now, I can’t.

### Visual Studio Code

All development of the launcher should be done using [Visual Studio Code][vscode].
Expand Down
84 changes: 84 additions & 0 deletions app/assets/athshield/athshield.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const fs = require('fs')
const readline = require('readline')
const path = require('path')

// Path to the configuration file
const configPath = path.join(__dirname, 'variables.athshield')

// Load the variables from the file
function loadConfig() {
const rawData = fs.readFileSync(configPath)
return JSON.parse(rawData.toString()) // Convert Buffer to string
}

// Save the variables to the file
function saveConfig(config) {
const data = JSON.stringify(config, null, 2)
fs.writeFileSync(configPath, data)
}

// Create the readline interface
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})

// Function to ask questions to the user
function startCLI() {
const config = loadConfig()

rl.question('Would you like to activate Athena\'s Shield? (yes/no): ', (answer) => {
if (answer.trim().startsWith('//')) {
console.log('This is a comment; the line is ignored.')
rl.close()
return
}

if (answer.toLowerCase() === 'yes') {
config.athenaShieldActivated = true

rl.question('Would you like to activate debug mode? (yes/no): ', (debugAnswer) => {
config.debug = debugAnswer.toLowerCase() === 'yes' // Set debug to true or false

rl.question('Would you like to hide or block the menu? (hide/block): ', (menuAnswer) => {
if (menuAnswer.trim().startsWith('//')) {
console.log('This is a comment; the line is ignored.')
rl.close()
return
}

if (menuAnswer.toLowerCase() === 'hide') {
config.menuVisibility = 'hidden' // Set to 'hidden'
console.log('Athena\'s Shield activated. Menu hidden.')
} else if (menuAnswer.toLowerCase() === 'block') {
config.menuVisibility = 'blocked' // Set to 'blocked'
console.log('Athena\'s Shield activated. Menu blocked.')
} else {
console.log('Invalid option for the menu.')
rl.close()
return
}

// Save the modified configuration
saveConfig(config)
rl.close()
})
})
} else if (answer.toLowerCase() === 'no') {
console.log('Athena\'s Shield not activated. Closing the CLI.')
config.athenaShieldActivated = false
config.menuVisibility = 'visible' // Reset to default
config.debug = 'false'

// Save the modified configuration
saveConfig(config)
rl.close()
} else {
console.log('Invalid response.')
rl.close()
}
})
}

// Launch the CLI
startCLI()
37 changes: 37 additions & 0 deletions app/assets/athshield/parserAthShield.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the comments in french?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started my code in French, but I had to translate it into English, and this is the only file I didn’t translate—a lapse in attention.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs')
const path = require('path')

// Chemin vers le fichier de configuration
const configPath = path.join(__dirname, 'variables.athshield')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply use a json extension?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vais faire en sorte d'utiliser un fichier json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make sure to use a JSON file.


// Classe pour gérer Athena's Shield
class AthenaShield {
constructor() {
this.config = this.loadConfig()
}

// Charger les variables depuis le fichier
loadConfig() {
const rawData = fs.readFileSync(configPath)
return JSON.parse(rawData.toString())
}

// Récupérer le statut d'Athena's Shield
get status() {
return this.config.athenaShieldActivated
}

// Récupérer la visibilité du menu
get type() {
return this.config.menuVisibility
}

// Récupérer le mode debug
get debug() {
return this.config.debug
}
}

// Exporter une instance de la classe
const athenaShieldInstance = new AthenaShield()
module.exports = athenaShieldInstance
5 changes: 5 additions & 0 deletions app/assets/athshield/variables.athshield
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"athenaShieldActivated": false,
"menuVisibility": "visible",
"debug": "false"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why not use a json file
Also please add a new line at the end of this file.

Suggested change
{
"athenaShieldActivated": false,
"menuVisibility": "visible",
"debug": "false"
}
{
"athenaShieldActivated": false,
"menuVisibility": "visible",
"debug": "false"
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it about the JSON file, and I’ll add a line at the end.

15 changes: 14 additions & 1 deletion app/assets/js/configmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@ const logger = LoggerUtil.getLogger('ConfigManager')

const sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME)

const dataPath = path.join(sysRoot, '.helioslauncher')
const nameDataPath = '.helioslauncher'

const dataPath = path.join(sysRoot, nameDataPath)

const launcherDir = require('@electron/remote').app.getPath('userData')

/**
* The path to the data directory used by the application.
* This variable can be used to retrieve or set the location
* where the application's data files are stored.
*
* @type {string}
*/
exports.getNameDataPath = function(){
return nameDataPath
}

/**
* Retrieve the absolute path of the launcher directory.
*
Expand Down
Loading