Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
Lack validation : Parameter exposed to external callers Python

I run CodeGuru CodeReview in my project, I got following recommendation.

For this line : return locale_alias[language][message]

Problem: This line of code lacks validation when processing input data through the following parameter: 'message' (index: 1 | type: Unknown). The parameter is exposed to external callers, because its enclosing class and method are publicly accessible. This means that upstream validation, if it exists, can be bypassed. Other validated parameters: 'language'.Malicious, malformed, or unbounded inputs can cause unexpected runtime behavior or crashes, and can slow performance

Public method parameters should be validated for nullness, unexpected values, and malicious values. Invalid or malicious input can compromise the system's safety.

Here is the code structure of my project.

strings.py

TESTING_ME = "Testing language"

strings_fr.py

TESTING_ME = "French Testing language French"

strings_en.py

TESTING_ME = "English Testing language English"

string_class.py

import strings_handler    

# class to handle strings_handler based on message and language select from endpoint
class Locale:
    def __init__(self, language, message):
        self.string = strings_handler.select_locale(language, message)

strings_handler.py

  import strings as key

  def select_locale(language, message): 

      if language == "fr"  
          import strings_fr as strings
      else:
          import strings_en as strings
      locale_alias = {language:
        {key.TESTING_ME : strings.TESTING_ME }            
        }
      return locale_alias[language][message]

In api call

import Locale
from typing import Optional
from fastapi import APIRouter
router = APIRouter()

@router.post("/test")
async def test_program(language:Optional[str] = "en"):
     return JSONResponse(
        status_code=header_status,
        content={
            "message": Locale(language, strings.TESTING_ME).string
        }
    )

How to ensure the validity of parameters's value (message)?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda