From bb1d687de50c39e8b6ee7c94415138fdda80e79b Mon Sep 17 00:00:00 2001 From: Jordan Terry <19422700+jkterry1@users.noreply.github.com> Date: Sun, 2 Aug 2026 14:24:04 -0400 Subject: [PATCH] Potential fix for code scanning alert no. 7: Clear-text storage of sensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- cores/flycast/intl/initial_sync.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cores/flycast/intl/initial_sync.py b/cores/flycast/intl/initial_sync.py index 1df39efc6..0a2f7d775 100644 --- a/cores/flycast/intl/initial_sync.py +++ b/cores/flycast/intl/initial_sync.py @@ -24,18 +24,19 @@ DIR_PATH = os.path.dirname(os.path.realpath(__file__)) YAML_PATH = os.path.join(DIR_PATH, 'crowdin.yaml') - # Apply Crowdin API Key + # Apply non-sensitive Crowdin config changes (core name only). + # Do NOT write API token into YAML; provide it via environment variable at runtime. with open(YAML_PATH, 'r') as crowdin_config_file: crowdin_config = crowdin_config_file.read() - crowdin_config = re.sub(r'"api_token": "_secret_"', - f'"api_token": "{API_KEY}"', - crowdin_config, 1) crowdin_config = re.sub(r'/_core_name_', f'/{CORE_NAME}' , crowdin_config) with open(YAML_PATH, 'w') as crowdin_config_file: crowdin_config_file.write(crowdin_config) + crowdin_env = os.environ.copy() + crowdin_env['CROWDIN_PERSONAL_TOKEN'] = API_KEY + try: # Download Crowdin CLI jar_name = 'crowdin-cli.jar' @@ -59,8 +60,8 @@ shutil.rmtree(jar_dir) print('upload source & translations *.json') - subprocess.run(['java', '-jar', jar_path, 'upload', 'sources', '--config', YAML_PATH]) - subprocess.run(['java', '-jar', jar_path, 'upload', 'translations', '--config', YAML_PATH]) + subprocess.run(['java', '-jar', jar_path, 'upload', 'sources', '--config', YAML_PATH], env=crowdin_env) + subprocess.run(['java', '-jar', jar_path, 'upload', 'translations', '--config', YAML_PATH], env=crowdin_env) print('wait for crowdin server to process data') time.sleep(10) @@ -108,12 +109,9 @@ workflow.write(workflow_config) except Exception as e: - # Try really hard to reset Crowdin API Key + # Revert non-sensitive YAML mutation (core name placeholder). with open(YAML_PATH, 'r') as crowdin_config_file: crowdin_config = crowdin_config_file.read() - crowdin_config = re.sub(r'"api_token": ".*?"', - '"api_token": "_secret_"', - crowdin_config, 1) # TODO this is NOT safe! crowdin_config = re.sub(re.escape(f'/{CORE_NAME}'),