SQLインジェクション対策について
教育的な観点ではなく実務的な観点から、僕の考えをまとめてみる。UTF-8 を利用し、SET NAMES を利用していなくて mysql で、クライアントプリペアドステートメントなケースを想定している。
$foo=$_POST[‘id’];
query(“SELECT * FROM foo WHERE id=$foo”);
のように外部からの文字列をそのまま使用してクエリを組みたてたときに、意図せぬ SQL を発行されてしまう脆弱性のことである。
--- | |
openapi: 3.0.3 | |
info: | |
title: Example | |
version: 1.0.0 | |
servers: | |
- url: 'https://example.com/' | |
paths: | |
/callback: |
import java.io.Closeable; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.net.URI; | |
import java.nio.ByteBuffer; | |
import java.nio.channels.*; | |
import java.nio.charset.StandardCharsets; | |
import java.util.*; | |
import java.util.logging.Logger; |
#!/usr/bin/env perl | |
use strict; | |
&main; exit; | |
sub main { | |
my %white = map { $_ => 1 } qw/ | |
kt java pl js rb py | |
/; |
self.addEventListener('message', function(e){ | |
setInterval(function(){ | |
self.postMessage('tick'); | |
}, 1000); | |
}, false); |
import java.time.LocalDateTime; | |
import java.time.ZoneId; | |
import java.time.ZonedDateTime; | |
import java.time.format.DateTimeFormatter; | |
import java.util.Locale; | |
public class DateTimeFormatterSample { | |
public static void main(String[] args) { | |
String[][] patterns = new String[][]{ | |
new String[]{"G", "appendText(ChronoField.ERA,"}, |
" ************************************************************************* | |
" tokuhirom's .vimrc file. | |
" | |
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
" | |
" | |
" :e ++enc=cp932 | |
" | |
" ************************************************************************* |
package com.example; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.InjectMocks; | |
import org.mockito.runners.MockitoJUnitRunner; | |
import java.util.HashMap; | |
import java.util.Map; |
#! /usr/bin/env bash | |
# Install any build dependencies needed for curl | |
sudo apt-get build-dep curl | |
# Get latest (as of Feb 25, 2016) libcurl | |
mkdir ~/curl | |
cd ~/curl | |
wget http://curl.haxx.se/download/curl-7.50.2.tar.bz2 | |
tar -xvjf curl-7.50.2.tar.bz2 |
Calling a XS function many times makes overhead. I recommend to run a for-loop in XS. It makes 155% faster than original implementation. (I want to generate a lot of β dsitribution random numbers)