Skip to content

Commit

Permalink
Fix QLDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Jan 20, 2025
1 parent 489a87f commit d472dfe
Showing 1 changed file with 26 additions and 61 deletions.
87 changes: 26 additions & 61 deletions go/ql/lib/semmle/go/frameworks/RsCors.qll
Original file line number Diff line number Diff line change
@@ -1,70 +1,52 @@
/**
* Provides classes for modeling the `github.com/rs/cors` package.
*/
/** Provides classes for modeling the `github.com/rs/cors` package. */

import go

/**
* An abstract class for modeling the Go CORS handler model origin write.
*/
/** An abstract class for modeling the Go CORS handler model origin write. */
abstract class UniversalOriginWrite extends DataFlow::ExprNode {
/**
* Get config variable holding header values
*/
/** Gets the config variable holding header values. */
abstract DataFlow::Node getBase();

/**
* Get config variable holding header values
*/
/** Gets the config variable holding header values. */
abstract Variable getConfig();
}

/**
* An abstract class for modeling the Go CORS handler model allow all origins write.
* An abstract class for modeling the Go CORS handler model allow all origins
* write.
*/
abstract class UniversalAllowAllOriginsWrite extends DataFlow::ExprNode {
/**
* Get config variable holding header values
*/
/** Gets the config variable holding header values. */
abstract DataFlow::Node getBase();

/**
* Get config variable holding header values
*/
/** Gets the config variable holding header values. */
abstract Variable getConfig();
}

/**
* An abstract class for modeling the Go CORS handler model allow credentials write.
* An abstract class for modeling the Go CORS handler model allow credentials
* write.
*/
abstract class UniversalAllowCredentialsWrite extends DataFlow::ExprNode {
/**
* Get config struct holding header values
*/
/** Gets the config struct holding header values. */
abstract DataFlow::Node getBase();

/**
* Get config variable holding header values
*/
/** Gets the config variable holding header values. */
abstract Variable getConfig();
}

/**
* Provides classes for modeling the `github.com/rs/cors` package.
*/
/** Provides classes for modeling the `github.com/rs/cors` package. */
module RsCors {
/** Gets the package name `github.com/gin-gonic/gin`. */
string packagePath() { result = package("github.com/rs/cors", "") }

/**
* A new function create a new rs Handler
*/
/** The `New` function that creates a new rs Handler. */
class New extends Function {
New() { exists(Function f | f.hasQualifiedName(packagePath(), "New") | this = f) }
}

/**
* A write to the value of Access-Control-Allow-Credentials header
* A write to the value of Access-Control-Allow-Credentials header.
*/
class AllowCredentialsWrite extends UniversalAllowCredentialsWrite {
DataFlow::Node base;
Expand All @@ -77,14 +59,10 @@ module RsCors {
)
}

/**
* Get options struct holding header values
*/
/** Gets the options struct holding header values. */
override DataFlow::Node getBase() { result = base }

/**
* Get options variable holding header values
*/
/** Gets the options variable holding header values. */
override RsOptions getConfig() {
exists(RsOptions gc |
(
Expand All @@ -97,9 +75,7 @@ module RsCors {
}
}

/**
* A write to the value of Access-Control-Allow-Origins header
*/
/** A write to the value of Access-Control-Allow-Origins header. */
class AllowOriginsWrite extends UniversalOriginWrite {
DataFlow::Node base;

Expand All @@ -111,14 +87,10 @@ module RsCors {
)
}

/**
* Get options struct holding header values
*/
/** Gets the options struct holding header values. */
override DataFlow::Node getBase() { result = base }

/**
* Get options variable holding header values
*/
/** Gets the options variable holding header values. */
override RsOptions getConfig() {
exists(RsOptions gc |
(
Expand All @@ -132,7 +104,8 @@ module RsCors {
}

/**
* A write to the value of Access-Control-Allow-Origins of value "*", overriding AllowOrigins
* A write to the value of Access-Control-Allow-Origins of value "*",
* overriding `AllowOrigins`.
*/
class AllowAllOriginsWrite extends UniversalAllowAllOriginsWrite {
DataFlow::Node base;
Expand All @@ -145,14 +118,10 @@ module RsCors {
)
}

/**
* Get options struct holding header values
*/
/** Gets the options struct holding header values. */
override DataFlow::Node getBase() { result = base }

/**
* Get options variable holding header values
*/
/** Gets options variable holding header values. */
override RsOptions getConfig() {
exists(RsOptions gc |
(
Expand All @@ -165,9 +134,7 @@ module RsCors {
}
}

/**
* A variable of type Options that holds the headers to be set.
*/
/** A variable of type Options that holds the headers to be set. */
class RsOptions extends Variable {
SsaWithFields v;

Expand All @@ -176,9 +143,7 @@ module RsCors {
v.getType().hasQualifiedName(packagePath(), "Options")
}

/**
* Get variable declaration of Options
*/
/** Gets the SSA variable declaration of Options. */
SsaWithFields getV() { result = v }
}
}

0 comments on commit d472dfe

Please sign in to comment.