Zum Hauptinhalt springen
LIVE
CVSS 8.7CVE-2026-138099 | A vulnerability was identified in Tenda AC10U 1.18.6. Affected by this vulnerability is the function readUsb of the component ATE Service. Such manipulation leads to out-of-bounds write. The attack can be executed remotely. The exploit is publicly available and might be used.CVSS 6.9CVE-2026-138098 | A vulnerability was determined in weison-tech yii2-cms up to 1.0.2. Affected is an unknown function of the file protected/core/config/common.php of the component RBAC Authorization. This manipulation causes improper authorization. Remote exploitation of the attack is possible.CVSS 6.9CVE-2026-138097 | A vulnerability was found in weison-tech yii2-cms up to 1.0.2. This impacts the function isActive of the file AccessControl.php of the component RBAC Admin Module. The manipulation results in missing authorization. The attack may be launched remotely.CVSS 6.9CVE-2026-138096 | A vulnerability has been found in weison-tech yii2-cms up to 1.0.2. This affects an unknown function of the file protected/core/config/web.php of the component Admin Auto-Login Identity Cookie. The manipulation leads to improper authentication. The attack may be initiated remotely.CVSS 4.8CVE-2026-138094 | A security vulnerability has been detected in ggml-org llama.cpp up to 0.6.0. Impacted is the function ggml_acc_impl of the file ggml/src/ggml.c of the component ggml Handler. Such manipulation leads to numeric truncation error. The attack can only be performed from a local environment. Upgrading to version 0.7.0 is recommended to address this issue. The name of the patch is 8ae386707bed05f02354dbfc6fa5ee0cf58e5f0f. It is recommended to upgrade the affectedCVSS 6.9CVE-2026-138093 | A weakness has been identified in alexander-torosh yona-cms up to 0.5.0. This issue affects the function loginAction of the file app/modules/Admin/Controller/IndexController.php of the component Admin Login Endpoint. This manipulation causes sql injection. It is possible to initiate the attack remotely.CVSS 4.8CVE-2026-138092 | A security flaw has been discovered in ggml-org llama.cpp up to 0.8.0. This vulnerability affects the function ggml_roll of the file ggml/src/ggml.c of the component Ggml Tensor Library Roll Operation. The manipulation results in integer overflow. The attack needs to be approached locally. Upgrading to version 0.9.0 is able to resolve this issue. The patch is identified as 0978a6e9022fb9bd6874b86154ee304e81929b9f. It is suggested to upgrade the affected compCVSS 10.0CVE-2026-138091 | A vulnerability was identified in Tenda AC10U 15.03.06.48. This affects the function TendaTelnet of the file /goform/telnet of the component Web UI. The manipulation leads to missing authentication. The attack is possible to be carried out remotely. The exploit is publicly available and might be used.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

SQL: Data Constraints

Introdução Validar dados é uma responsabilidade que pode ficar na aplicação, no banco de dados, ou em ambos. Deixar tudo na aplicação é arriscado: diferentes si…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 5 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung




Introdução



Validar dados é uma responsabilidade que pode ficar na aplicação, no banco de dados, ou em ambos. Deixar tudo na aplicação é arriscado: diferentes sistemas podem acessar o mesmo banco, migrações podem rodar diretamente, um bug pode deixar passar um valor inválido. Constraints são regras definidas no próprio banco de dados — uma camada de proteção que age independente de quem está escrevendo os dados.






PRIMARY KEY



A chave primária identifica cada linha de forma única. Ela combina duas restrições implicitamente: NOT NULL e UNIQUE. Nenhuma linha pode ter o mesmo valor de chave primária, e nenhuma pode tê-la nula.




CREATE TABLE clientes (
id INT PRIMARY KEY,
nome VARCHAR(100) NOT NULL
);






Quando a chave primária envolve mais de uma coluna, ela é declarada separadamente:




CREATE TABLE matriculas (
aluno_id INT,
curso_id INT,
PRIMARY KEY (aluno_id, curso_id)
);






Na maioria dos bancos, é comum usar uma chave primária auto-incremental para não precisar gerenciar os IDs manualmente:




-- PostgreSQL
id SERIAL PRIMARY KEY

-- MySQL
id INT AUTO_INCREMENTPRIMARY KEY

-- SQL padrão (suportado por ambos)
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY









FOREIGN KEY



A chave estrangeira garante integridade referencial: um valor só pode existir numa coluna se ele existir como chave primária na tabela referenciada. É o que torna os relacionamentos entre tabelas confiáveis.




CREATE TABLE pedidos (
id INT PRIMARY KEY,
cliente_idINT REFERENCES clientes(id)
);






Tentar inserir um pedido com cliente_id = 99 quando não existe cliente com esse id resulta em erro imediato. O banco rejeita a operação antes mesmo de ela chegar ao disco.



O comportamento quando o registro referenciado é deletado pode ser configurado:




CREATE TABLE pedidos (
id INT PRIMARY KEY,
cliente_id INT REFERENCES clientes(id)
ON DELETE CASCADE -- deleta os pedidos junto com o cliente
ON UPDATE CASCADE -- atualiza o cliente_id se o id do cliente mudar
);






As opções disponíveis são:




























Opção Comportamento
RESTRICT Rejeita a operação se houver dependentes (padrão)
CASCADE Propaga a operação para os dependentes
SET NULL Define a FK como nula nos dependentes
SET DEFAULT Define a FK com o valor padrão da coluna





UNIQUE



Garante que todos os valores de uma coluna — ou combinação de colunas — sejam distintos. Diferente da chave primária, uma coluna UNIQUE pode conter NULL (e em geral múltiplos NULL são permitidos, pois NULL não é igual a nada, nem a si mesmo).




CREATE TABLE usuarios (
id INT PRIMARY KEY,
email VARCHAR(150) UNIQUE,
username VARCHAR(50) UNIQUE
);






UNIQUE composto funciona da mesma forma que PRIMARY KEY composto — a restrição se aplica à combinação, não às colunas individualmente:




-- O mesmo aluno pode ter notas em vários cursos,
-- mas não duas notas no mesmo curso
CREATE TABLE notas (
aluno_id INT,
curso_id INT,
notaDECIMAL(4,2),
UNIQUE (aluno_id, curso_id)
);









NOT NULL



Impede que uma coluna aceite ausência de valor. Simples e direto — mas uma das constraints mais importantes na prática, porque NULL se propaga de formas inesperadas em cálculos e comparações.




CREATE TABLE produtos (
id INT PRIMARY KEY,
nomeVARCHAR(100) NOT NULL,
precoDECIMAL(10,2) NOT NULL,
descricao TEXT -- aceita NULL: campo opcional
);






Uma coluna sem NOT NULL aceita NULL por padrão. Definir quais campos são obrigatórios e quais são opcionais é uma decisão de modelagem — e NOT NULL é a forma de documentar e enforçar isso no próprio esquema.



Vale lembrar: AVG, SUM e outras funções de agregação ignoram NULL automaticamente. E comparações com NULL usando = sempre retornam falso — NULL = NULL é falso em SQL; a verificação correta é IS NULL.






CHECK



Permite definir uma condição arbitrária que os valores de uma coluna precisam satisfazer. É a constraint mais flexível — qualquer expressão booleana válida pode ser usada.




CREATE TABLE produtos (
id INT PRIMARY KEY,
nome VARCHAR(100) NOT NULL,
preco DECIMAL(10,2) NOT NULL CHECK (preco>= 0),
estoque INT NOT NULL CHECK (estoque>= 0),
avaliacao DECIMAL(2,1)CHECK (avaliacaoBETWEEN 0 AND 5)
);






Tentar inserir um produto com preco = -50 vai gerar um erro de violação de constraint antes de qualquer dado ser gravado.



CHECK também pode referenciar múltiplas colunas da mesma linha:




CREATE TABLE descontos (
id INT PRIMARY KEY,
preco_original DECIMAL(10,2) NOT NULL,
preco_final DECIMAL(10,2) NOT NULL,
CHECK (preco_final<= preco_original)
);






Isso garante que nenhum desconto resulte em preço final maior que o original — uma regra de negócio simples que, sem CHECK, dependeria inteiramente da aplicação para ser respeitada.






Adicionando Constraints depois



Constraints podem ser adicionadas a tabelas existentes com ALTER TABLE:




ALTER TABLE produtos
ADD CONSTRAINT chk_preco CHECK (preco>= 0);

ALTER TABLE pedidos
ADD CONSTRAINT fk_cliente
FOREIGN KEY (cliente_id) REFERENCES clientes(id);






E removidas quando necessário:




ALTER TABLE produtos DROP CONSTRAINT chk_preco;









Por que usar Constraints



A alternativa às constraints é validar tudo na aplicação. O problema é que a aplicação não é a única forma de os dados chegarem ao banco — migrações, scripts de manutenção, ferramentas de BI, outros serviços. Constraints garantem que independente da origem, os dados respeitem as regras. É a diferença entre confiar que ninguém vai errar e tornar o erro impossível.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Communitydiscussie & reacties

🌐 Naar de hoofdchat

Start de discussie in de Social Chat broadcaststream of dien hierboven een vakbijdrage in via het aanvulformulier.

Community Rating &amp; Social Proof
⭐ Lezersbeoordeling
–
Ø / 5.0
Nog geen recensies van lezers
Was dit artikel nuttig?
0
Geef uw beoordeling
Detailbeoordeling (optioneel)
Inhoud & Kwaliteit
Bron & Geloofwaardigheid
Actualiteit
Security Briefing Gratis · 1-klik uitschrijven

Intelligence Digest gratis

Dagelijks het belangrijkste beveiligingsnieuws · kan op elk moment worden opgehaald

Verwant Story Cluster & Sources (vector AI)

4 Cluster
3 Bronnen
GitHub Release: can1357/oh-my-pi v19.3.0 (29.11.2026)
GitHub · can1357/oh-my-pi 20 uur geleden
2 andere bronnen
2 Bronnen
Mozilla Thanks Users For New Features in Firefox 161: Site-Specific VPN and Keyboard Shortcuts
Slashdot 1 dag geleden
1 een andere bron
Soortgelijke bijdragen
🔍 Verwandte News

Auch interessante Nachrichten SQL: Data Constraints

Thematisch verwandte Begriffe: Data, Constraints · 6 Treffer

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

Laden...

Bijdragen zijn geladen ...

Laden...

Video's zijn geladen...

💬 Reacties worden geladen…
Trek om te vernieuwen
Widgets & onderwerpen
Widgets laden…
Volgende bericht