Check-in [a58faea2e0]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use prefix/whitespace prepending for whole block (some macros just got the first line indented). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a58faea2e01de8e6d0eb9b7dc9793ab9 |
User & Date: | mario 2020-12-16 10:39:33 |
Context
2020-12-16
| ||
10:41 | Support user-recipes as .txt files check-in: ab9086bf82 user: mario tags: trunk | |
10:39 | Use prefix/whitespace prepending for whole block (some macros just got the first line indented). check-in: a58faea2e0 user: mario tags: trunk | |
10:35 | Bundle logfmt1 into sub project. Support for /usr/share/logfmt/ database and update scripts (apache version is a trimmed down modseccfg.vhosts extractor). Support both pip and deb package (differ to some extend). check-in: f0887760c8 user: mario tags: trunk | |
Changes
Changes to modseccfg/writer.py.
1 2 3 4 | # encoding: utf-8 # api: modseccfg # title: Writer # description: updates *.conf files with new directives | | | 1 2 3 4 5 6 7 8 9 10 11 12 | # encoding: utf-8 # api: modseccfg # title: Writer # description: updates *.conf files with new directives # version: 0.7 # type: file # category: config # config: # { name: write_etc, type: bool, value: 0, description: "Write to /etc without extra warnings", help: "Normally modseccfg would not update default apache/modsecurity config files." } # { name: write_sudo, type: bool, value: 0, description: "Use sudo to update non-writable files", help: "Run `sudo` on commandline to update files, if permissions insufficient" } # { name: backup_files, value: 1, type: bool, description: "Copy files to ~/backup-config/ before rewriting" } # { name: backup_dir, value: "~/backup-config/", type: str, description: "Where to store copies of configuration files" } |
︙ | ︙ | |||
119 120 121 122 123 124 125 | # detect leading whitespace def pfx(src): space = rx.pfx.findall(src) if space: return space[0] else: return "" | | > > > > | > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # detect leading whitespace def pfx(src): space = rx.pfx.findall(src) if space: return space[0] else: return "" # add leading space to all lines of insert block def prepend_pfx(add, pfx=""): if pfx: add = re.sub("^", pfx, add, re.M) return add #-- update methods -- # directive insertion doesn't look for context def append(fn, directive, value, comment=""): src = read(fn) insert = f"{directive} {value} {comment}\n" insert = prepend_pfx(insert, pfx(src)) rx_end = rx_end_preconf(fn) srcnew = rx_end.sub(insert, src, 1) write(fn, srcnew) # count ↑ =0 would insert before all </VirtualHost> markers # strip SecRuleRemoveById …? nnnnnnn …? def remove_remove(fn, directive, value): src = read(fn) |
︙ | ︙ |