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

Inclui novas variáveis de ambiente. #196

Merged
merged 20 commits into from
Dec 10, 2024

Conversation

samuelveigarangel
Copy link
Contributor

@samuelveigarangel samuelveigarangel commented Oct 16, 2024

O que esse PR faz?

Incluí novas váriaveis de ambiente.

Onde a revisão poderia começar?

Indique o caminho do arquivo e o arquivo onde o revisor deve iniciar a leitura do código.

Como este poderia ser testado manualmente?

Estabeleça os passos necessários para que a funcionalidade seja testada manualmente pelo revisor.

Algum cenário de contexto que queira dar?

De acordo com Readme do projeto opac_5, foi incluído novas variáveis.

Screenshots

N/A

Quais são tickets relevantes?

#184
#206

Referências

N/A

Copy link

gitguardian bot commented Oct 16, 2024

⚠️ GitGuardian has uncovered 3 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13840232 Triggered Generic High Entropy Secret ff66c41 .envs/.production-template/.flask View secret
13840232 Triggered Generic High Entropy Secret b51f7f6 .envs/.production-template/.flask View secret
13840232 Triggered Generic High Entropy Secret 7df7246 .envs/.production-template/.flask View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@gitnnolabs
Copy link
Collaborator

@samuelveigarangel @robertatakenaka sobre essa atividade tenho dúvida sobre a definição dela, me explico:

É para termos todas as variáveis de ambientes na pasta .envs? ou é para termos as variáveis mais utilizadas?

De fato olhando o PR e olhando os arquivos não temos todas as variáveis de ambiente no diretório .envs, exemplo:

  • GOOGLE_VERIFY_RECAPTCHA_KEY
  • GOOGLE_RECAPTCHA_SECRET_KEY

Esse é um exemplo de variável que deve está em .envs pensado nos países é uma variável que deve ser trocada, cada país deve term sua conta de recaptcha.

A variável DEFAULT_EMAIL e OPAC_EMAIL_ACCOUNTS_RECEIVE_ERRORS são outros exemplos.

Sugiro que todos as variáveis de ambiente estejam nesses arquivos da pasta .envs ou tenha um cabeçalho que indica as variáveis, assim com existe no arquivo default.py que indicar todas as variáveis de ambiente possíveis.

Vejam: https://github.com/scieloorg/opac_5/blob/master/opac/webapp/config/default.py#L6

@@ -21,12 +21,24 @@ OPAC_SECRET_KEY=NWhWFn_ScpW6YR9yJKDLxg
# Name for MongoDB host
OPAC_MONGODB_HOST=opac_mongo

# Activate/Desactivate the cache of redis (default: True)
# Activate/Desactivate the cache of redis (default: False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Show.

Comment on lines 44 to 47
- ./.envs/.production-template/.flask
- ./.envs/.production-template/.redis
- ./.envs/.production-template/.monitoring-apm
- ./.envs/.production-template/.metrics
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel manter .production

Copy link
Member

@robertatakenaka robertatakenaka Nov 12, 2024

Choose a reason for hiding this comment

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

@samuelveigarangel o .envs/.production-template é para que ao baixar não sobrescreva o .envs/.production existente

@robertatakenaka
Copy link
Member

@samuelveigarangel variáveis duplicadas, remover do redis:

# True or False
OPAC_CACHE_ENABLED=True

# Cache timeout (in seconds). Ex: 3600
OPAC_CACHE_DEFAULT_TIMEOUT=3600

OPAC_CACHE_CONTROL_MAX_AGE_HEADER=604800


OPAC_FORCE_USE_HTTPS_GOOGLE_TAGS
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel faltou o = com o valor default

@@ -4,6 +4,30 @@
# This set the IP that the app will bind to run, default: 0.0.0.0
OPAC_SERVER_NAME=0.0.0.0

# Domain for the session cookie (default: OPAC_SERVER_NAME)
OPAC_SESSION_COOKIE_DOMAIN=OPAC_SERVER_NAME
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel o valor default não pode ser OPAC_SERVER_NAME

@@ -0,0 +1,15 @@
# -------------------- Twitter ----------------------
Copy link
Member

Choose a reason for hiding this comment

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

@samuelveigarangel mover estas variáveis para o .flask

@robertatakenaka robertatakenaka changed the title Incluí novas variáveis de ambiente. Inclui novas variáveis de ambiente. Nov 22, 2024
@gitnnolabs
Copy link
Collaborator

Validando esse PR...

@gitnnolabs
Copy link
Collaborator

gitnnolabs commented Dec 10, 2024

Rodando localmente tive o seguinte erro:

Screenshot 2024-12-10 at 10 54 42

Para resolver esse ponto é necessário somente envolver o valor de por aspas "Creative Common - by 4.0"

Screenshot 2024-12-10 at 11 40 52

Percebi que está faltando as seguintes variáveis de ambiente nos arquivos .envs:

MAIL_USERNAME = os.environ.get("OPAC_MAIL_USERNAME", None)
MAIL_PASSWORD = os.environ.get("OPAC_MAIL_PASSWORD", None)
THUMBNAIL_HEIGHT = os.environ.get("THUMBNAIL_HEIGHT", 100)
THUMBNAIL_WIDTH = os.environ.get("THUMBNAIL_WIDTH", 100)
DIMENSIONS_METRICS_URL = os.environ.get("OPAC_DIMENSIONS_METRICS_URL","https://badge.dimensions.ai/details/doi")
USE_SCIENCEOPEN = os.environ.get("OPAC_USE_SCIENCEOPEN", "False") == "True"
BUILD_DATE = os.environ.get("OPAC_BUILD_DATE", None)
VCS_REF = os.environ.get("OPAC_VCS_REF", None)
WEBAPP_VERSION = os.environ.get("OPAC_WEBAPP_VERSION", None)
READCUBE_ENABLED = os.environ.get("OPAC_READCUBE_ENABLED", "False") == "True"SSM_XML_URL_REWRITE
HTML_GENERATOR_VERSION = os.environ.get("HTML_GENERATOR_VERSION", "3.0")
OPAC_SCHEME = os.environ.get("OPAC_OPAC_SCHEME", "https")
SEND_FILE_MAX_AGE_DEFAULT = os.environ.get("OPAC_SEND_FILE_MAX_AGE_DEFAULT", 604800)
CACHE_CONTROL_MAX_AGE_HEADER = os.environ.get(
    "OPAC_CACHE_CONTROL_MAX_AGE_HEADER", 604800
)
PINGDOM_VISITOR_INSIGHTS_JS_SRC = os.environ.get(
    "OPAC_PINGDOM_VISITOR_INSIGHTS_JS_SRC", None
)
SCIMAGO_URL = os.environ.get(
    "SCIMAGO_URL", "https://www.scimagojr.com/journalsearch.php?tip=sid&clean=0&q="
)
SCIMAGO_ENABLED = os.environ.get("SCIMAGO_ENABLED", "True") == "True"SCIMAGO_URL_IR
SCIMAGO_URL_IR = os.environ.get("SCIMAGO_URL_IR", "https://www.scimagoir.com/")MAILING_CRON_STRING
MAILING_CRON_STRING = os.environ.get("OPAC_MAILING_CRON_STRING", "0 7 * * *")
DEFAULT_SCHEDULER_TIMEOUT = int(os.environ.get("OPAC_DEFAULT_SCHEDULER_TIMEOUT", 1000))
MATHJAX_CDN_URL = os.environ.get("OPAC_MATHJAX_CDN_URL", DEFAULT_MATHJAX_CDN_URL)
OPAC_GOOGLE_SCHOLAR_LINK = os.environ.get(
    "OPAC_GOOGLE_SCHOLAR", "https://scholar.google.com/scholar?q="
)
OPAC_GOOGLE_LINK = os.environ.get("OPAC_GOOGLE", "https://www.google.com/search?q=")
APM_SERVICE_VERSION = os.environ.get("OPAC_APM_SERVICE_VERSION")
APM_FILTER_EXCEPTION_TYPES = os.environ.get("OPAC_APM_FILTER_EXCEPTION_TYPES")
APM_TRANSACTIONS_IGNORE_PATTERNS = os.environ.get(
    "OPAC_APM_TRANSACTIONS_IGNORE_PATTERNS"
)
APM_SERVER_TIMEOUT = os.environ.get("OPAC_APM_SERVER_TIMEOUT")
APM_HOSTNAME = os.environ.get("OPAC_APM_HOSTNAME")
APM_COLLECT_LOCAL_VARIABLES = os.environ.get("OPAC_APM_COLLECT_LOCAL_VARIABLES")
APM_LOCAL_VAR_MAX_LENGTH = os.environ.get("OPAC_APM_LOCAL_VAR_MAX_LENGTH")
APM_CAPTURE_BODY = os.environ.get("OPAC_APM_CAPTURE_BODY")
APM_CAPTURE_HEADERS = os.environ.get("OPAC_APM_CAPTURE_HEADERS", True)
APM_TRANSACTION_MAX_SPANS = os.environ.get("OPAC_APM_TRANSACTION_MAX_SPANS")
APM_STACK_TRACE_LIMIT = os.environ.get("OPAC_APM_STACK_TRACE_LIMIT")
APM_DEBUG = os.environ.get("OPAC_APM_DEBUG", False)
APM_DISABLE_SEND = os.environ.get("OPAC_APM_DISABLE_SEND", False)
APM_INSTRUMENT = os.environ.get("OPAC_APM_INSTRUMENT", True)
APM_VERIFY_SERVER_CERT = os.environ.get("OPAC_APM_APM_VERIFY_SERVER_CERT", True)
PREVIOUS_WEBSITE_URI = os.environ.get("PREVIOUS_WEBSITE_URI", "")
ALERT_MSG_PT = os.environ.get("ALERT_MSG_PT", "")
ALERT_MSG_EN = os.environ.get("ALERT_MSG_EN", "")
ALERT_MSG_ES = os.environ.get("ALERT_MSG_ES", "")
ALERT_MSG = bool(ALERT_MSG_PT or ALERT_MSG_EN or ALERT_MSG_ES)
ACCESSIBILITY_BY_LANGUAGE = {
    "pt_BR": os.environ.get(
        "ACCESSIBILITY_FORM_PT", "https://forms.gle/2Vpt2z26uGqHA7yy5"
    ),
    "en": os.environ.get(
        "ACCESSIBILITY_FORM_EN", "https://forms.gle/qHwovmddXdZRDxjm7"
    ),
    "es": os.environ.get(
        "ACCESSIBILITY_FORM_ES", "https://forms.gle/XZuJurSVMBp4E64j6"
    ),
}
JOURNAL_PAGES_ORIGINAL_WEBSITE = os.environ.get("ORIGINAL_WEBSITE") or ""

Reparei que a variável OPAC_CACHE_ENABLED, está repetida em dois arquivos .flask e .redis

Sobre a variável de ambiente BABEL_DEFAULT_LOCALE, considerando que estamos instalando em outros países..... hoje ela que determina o valor padrão dos labels para tradução, mas isso é ruim... por que imagina a tradução será de português para qualquer idioma no passo nosso idioma não é universal como o Inglês, isso é um ponto para o futuro.

BABEL_DEFAULT_LOCALE = "pt_BR"

A lista completa de variáveis em lista:

[DEBUG, TESTING, LOG_LEVEL, ASSETS_DEBUG, MINIFY_PAGE, WEBMASTER_EMAIL, USE_HOME_METRICS, OPAC_COLLECTION, DEFAULT_EMAIL, EMAIL_ACCOUNTS_RECEIVE_ERRORS, MAIL_SERVER, MAIL_PORT, MAIL_USE_TLS, MAIL_USE_SSL, MAIL_DEBUG, MAIL_USERNAME, MAIL_PASSWORD, MAIL_DEFAULT_SENDER, MAIL_MAX_EMAILS, MAIL_ASCII_ATTACHMENTS, SECRET_KEY, MONGODB_NAME, MONGODB_HOST, MONGODB_PORT, MONGODB_USER, MONGODB_PASS, MONGODB_SETTINGS, DATABASE_FILE, DATABASE_DIR, DATABASE_PATH, SQLALCHEMY_DATABASE_URI, SQLALCHEMY_ECHO, SQLALCHEMY_TRACK_MODIFICATIONS, TOKEN_MAX_AGE, LANGUAGES, BABEL_DEFAULT_LOCALE, LOCAL_ZONE, GA_TRACKING_CODE, DEBUG_TB_INTERCEPT_REDIRECTS, DATA_PATH, JOURNAL_PAGES_ORIGINAL_WEBSITE, JOURNAL_PAGES_SOURCE_PATH, JOURNAL_IMAGES_SOURCE_PATH, DEFAULT_MEDIA_ROOT, MEDIA_ROOT, IMAGE_ROOT, FILE_ROOT, MEDIA_URL, FILES_ALLOWED_EXTENSIONS, IMAGES_ALLOWED_EXTENSIONS, IMAGES_ALLOWED_EXTENSIONS_RE, THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, URL_SCIELO_ORG, SCIELO_ORG_URIS, URL_BLOG_SCIELO, URL_SEARCH, URL_BLOG_PRESSRELEASE, USE_METRICS, METRICS_URL, USE_DIMENSIONS, DIMENSIONS_METRICS_URL, USE_PLUMX, PLUMX_METRICS_URL, PLUMX_METRICS_JS, USE_ALTMETRIC, ALTMETRIC_METRICS_URL, USE_SCIENCEOPEN, USE_SCITE, SCITE_URL, SCITE_METRICS_URL, ORCID_URL, NEWS_LIST_LIMIT, DEBUG_TB_PANELS, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET, TWITTER_SCREEN_NAME, TWITTER_LIMIT, USE_SENTRY, SENTRY_DSN, BUILD_DATE, VCS_REF, WEBAPP_VERSION, OPAC_WTF_CSRF_ENABLED, OPAC_WTF_CSRF_SECRET_KEY, READCUBE_ENABLED, SSM_SCHEME, SSM_DOMAIN, SSM_PORT, SSM_MEDIA_PATH, SSM_XML_URL_REWRITE, SSM_ARTICLE_ASSETS_OR_RENDITIONS_URL_REWRITE, HTML_GENERATOR_VERSION, SSM_BASE_URI, SSM_MEDIA_URI, OPAC_SCHEME, SERVER_NAME, OPAC_BASE_URI, SESSION_COOKIE_DOMAIN, SESSION_COOKIE_HTTPONLY, SESSION_COOKIE_NAME, SESSION_COOKIE_PATH, SESSION_COOKIE_SECURE, SESSION_REFRESH_EACH_REQUEST, CACHE_ENABLED, CACHE_TYPE, CACHE_NO_NULL_WARNING, CACHE_DEFAULT_TIMEOUT, CACHE_KEY_PREFIX, CACHE_REDIS_HOST, CACHE_REDIS_PORT, CACHE_REDIS_DB, CACHE_REDIS_PASSWORD, SEND_FILE_MAX_AGE_DEFAULT, CACHE_CONTROL_MAX_AGE_HEADER, PINGDOM_VISITOR_INSIGHTS_JS_SRC, GOOGLE_RECAPTCHA_SECRET_KEY, GOOGLE_RECAPTCHA_URL, GOOGLE_VERIFY_RECAPTCHA_URL, GOOGLE_VERIFY_RECAPTCHA_KEY, SCIMAGO_URL, SCIMAGO_ENABLED, SCIMAGO_URL_IR, AUDIT_LOG_NOTIFICATION_ENABLED, _audit_log_notification_recipients, AUDIT_LOG_NOTIFICATION_RECIPIENTS, REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, RQ_REDIS_URL, RQ_REDIS_SETTINGS, MAILING_CRON_STRING, DEFAULT_SCHEDULER_TIMEOUT, DEFAULT_MATHJAX_CDN_URL, MATHJAX_CDN_URL, OPAC_GOOGLE_SCHOLAR_LINK, OPAC_GOOGLE_LINK, COOKIE_POLICY_ENABLED, COOKIE_POLICY_URL, APM_ENABLED, APM_SERVER_URL, APM_SERVICE_NAME, APM_SECRET_TOKEN, APM_ENVIRONMENT, APM_SERVICE_VERSION, APM_FILTER_EXCEPTION_TYPES, APM_TRANSACTIONS_IGNORE_PATTERNS, APM_SERVER_TIMEOUT, APM_HOSTNAME, APM_COLLECT_LOCAL_VARIABLES, APM_LOCAL_VAR_MAX_LENGTH, APM_CAPTURE_BODY, APM_CAPTURE_HEADERS, APM_TRANSACTION_MAX_SPANS, APM_STACK_TRACE_LIMIT, APM_DEBUG, APM_DISABLE_SEND, APM_INSTRUMENT, APM_VERIFY_SERVER_CERT, PREVIOUS_WEBSITE_URI, ALERT_MSG_PT, ALERT_MSG_EN, ALERT_MSG_ES, ALERT_MSG, FORCE_USE_HTTPS_GOOGLE_TAGS, FILTER_SECTION_ENABLE, FILTER_SECTION_ENABLE_FOR_MIN_STUDY_AREAS, ACCESSIBILITY_BY_LANGUAGE, COMMON_STYLE_LIST, CITATION_EXPORT_FORMATS, SITE_LICENSE_ENABLE, SITE_LICENSE_NAME, SITE_LICENSE_URL, SITE_LICENSE_IMG_URL]

Copy link
Collaborator

@gitnnolabs gitnnolabs left a comment

Choose a reason for hiding this comment

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

@samuelveigarangel verifique por gentileza meus comentários.

@scieloorg scieloorg deleted a comment from robertatakenaka Dec 10, 2024
@gitnnolabs
Copy link
Collaborator

Good job.

@gitnnolabs gitnnolabs merged commit 49247e9 into scieloorg:master Dec 10, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants