Add getHeaderValue predicate to HTTP::HeaderWrite

This commit is contained in:
Sauyon Lee
2020-12-15 11:02:11 -08:00
parent 39c33c5db1
commit bf9bba79c2
3 changed files with 13 additions and 5 deletions

View File

@@ -64,10 +64,17 @@ module HTTP {
/** Gets the (lower-case) name of a header set by this definition. */
string getHeaderName() { result = this.getName().getStringValue().toLowerCase() }
/** Gets the value of the header set by this definition. */
string getHeaderValue() {
result = this.getValue().getStringValue()
or
result = this.getValue().getIntValue().toString()
}
/** Holds if this header write defines the header `header`. */
predicate definesHeader(string header, string value) {
header = this.getHeaderName() and
value = this.getValue().getStringValue()
value = this.getHeaderValue()
}
/**
@@ -101,6 +108,9 @@ module HTTP {
/** Gets the (lower-case) name of a header set by this definition. */
string getHeaderName() { result = self.getHeaderName() }
/** Gets the value of the header set by this definition. */
string getHeaderValue() { result = self.getHeaderValue() }
/** Holds if this header write defines the header `header`. */
predicate definesHeader(string header, string value) { self.definesHeader(header, value) }

View File

@@ -108,9 +108,7 @@ module NetHttp {
override string getHeaderName() { result = "status" }
override predicate definesHeader(string header, string value) {
header = "status" and value = this.getValue().getIntValue().toString()
}
override string getHeaderValue() { result = this.getValue().getIntValue().toString() }
override DataFlow::Node getName() { none() }

View File

@@ -3,9 +3,9 @@ package main
import (
"bytes"
"fmt"
"html"
"io"
"io/ioutil"
"net/html"
"net/http"
)