32 lines
799 B
C++
32 lines
799 B
C++
#pragma once
|
|||
|
|
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
#include "csp/csp_policy.hpp"
|
||
|
|
|
||
|
|
namespace molo::csp {
|
||
|
|
|
||
|
|
// Fluent builder. Default is deny-first per 09-cli-ops.md rule 10.
|
||
|
|
class CspBuilder {
|
||
|
|
public:
|
||
|
|
CspBuilder();
|
||
|
|
|
||
|
|
CspBuilder& default_src(const std::string& value);
|
||
|
|
CspBuilder& script_src(const std::string& value);
|
||
|
|
CspBuilder& style_src(const std::string& value);
|
||
|
|
CspBuilder& img_src(const std::string& value);
|
||
|
|
CspBuilder& connect_src(const std::string& value);
|
||
|
|
CspBuilder& frame_ancestors(const std::string& value);
|
||
|
|
CspBuilder& report_to(const std::string& value);
|
||
|
|
CspBuilder& script_nonce(const std::string& nonce_base64);
|
||
|
|
CspBuilder& enforce();
|
||
|
|
|
||
|
|
CspPolicy build() const;
|
||
|
|
|
||
|
|
private:
|
||
|
|
std::map<std::string, std::string> directives_;
|
||
|
|
bool report_only_ = true;
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace molo::csp
|