1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-09-11 18:27:21 +03:00

feat: sanitize current OS profile session name for better privacy

This commit is contained in:
louistiti 2023-04-23 22:12:19 +08:00
parent 075f4458a0
commit fe580cfb92
No known key found for this signature in database
GPG Key ID: 92CD6A2E497E1669
2 changed files with 42 additions and 28 deletions

View File

@ -43,34 +43,6 @@ dotenv.config()
const skillsResolversNlpModelPath =
'core/data/models/leon-skills-resolvers-model.nlp'
const mainNlpModelPath = 'core/data/models/leon-main-model.nlp'
const pastebinData = {
leonVersion: null,
environment: {
osDetails: null,
nodeVersion: null,
npmVersion: null
},
nlpModels: {
globalResolversModelState: null,
skillsResolversModelState: null,
mainModelState: null
},
pythonBridge: {
version: null,
executionTime: null,
command: null,
output: null,
error: null
},
tcpServer: {
version: null,
startTime: null,
command: null,
output: null,
error: null
},
report: null
}
const report = {
can_run: { title: 'Run', type: 'error', v: true },
can_run_skill: { title: 'Run skills', type: 'error', v: true },
@ -116,6 +88,34 @@ dotenv.config()
v: true
}
}
let pastebinData = {
leonVersion: null,
environment: {
osDetails: null,
nodeVersion: null,
npmVersion: null
},
nlpModels: {
globalResolversModelState: null,
skillsResolversModelState: null,
mainModelState: null
},
pythonBridge: {
version: null,
executionTime: null,
command: null,
output: null,
error: null
},
tcpServer: {
version: null,
startTime: null,
command: null,
output: null,
error: null
},
report: null
}
LogHelper.title('Checking')
@ -527,6 +527,10 @@ dotenv.config()
pastebinData.report = report
pastebinData = JSON.parse(
SystemHelper.sanitizeUsername(JSON.stringify(pastebinData))
)
LogHelper.title('REPORT URL')
LogHelper.info('Sending report...')

View File

@ -137,4 +137,14 @@ export class SystemHelper {
'0.0.0'
)
}
/**
* Replace all current session profile name occurrences with {username} placeholder
* @example sanitizeUsername('/home/louis') // '/home/{username}'
*/
public static sanitizeUsername(str: string): string {
const { username } = os.userInfo()
return str.replace(new RegExp(username, 'g'), '{username}')
}
}