home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

decode-kubernetes-secrets.py (1177B)


      1 #! /usr/bin/env nix-shell
      2 #! nix-shell -i python3 -p python3 -p python37Packages.pyaml
      3 # -*- coding: utf-8 -*-
      4 # Author: Chmouel Boudjnah <chmouel@chmouel.com>
      5 #
      6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
      7 # not use this file except in compliance with the License. You may obtain
      8 # a copy of the License at
      9 #
     10 #      http://www.apache.org/licenses/LICENSE-2.0
     11 #
     12 # Unless required by applicable law or agreed to in writing, software
     13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     15 # License for the specific language governing permissions and limitations
     16 # under the License.
     17 import yaml
     18 import base64
     19 import sys
     20 
     21 try:
     22     from yaml import CLoader as Loader, CDumper as Dumper
     23 except ImportError:
     24     from yaml import Loader, Dumper
     25 
     26 if len(sys.argv[0]):
     27     stream = sys.stdin
     28 else:
     29     stream = open(sys.argv[1])
     30 data = yaml.load(stream, Loader=Loader)
     31 for d in data['data'].items():
     32     if d[1] and d[1].endswith("="):
     33         print("Key: " + d[0] + " \nValue: \n" + \
     34               base64.b64decode(d[1]).decode('utf-8'))
     35         print("\n")